main()

{

char a[4]="HELLO";

printf("%s",a);

}

Answers were Sorted based on User's Feedback



main() { char a[4]="HELLO"; printf("%s",a); ..

Answer / dani

Actually I compiled this and ran it unix and it just prints out a warning, not an error:
"warning: initializer-string for array of chars is too long"

The programme prints the initial array without the last character (because of the '\0' special character):
"HELL �"

Is This Answer Correct ?    5 Yes 1 No

main() { char a[4]="HELLO"; printf("%s",a); ..

Answer / smk

too many intializer for a[4](warning)

Is This Answer Correct ?    3 Yes 0 No

main() { char a[4]="HELLO"; printf("%s",a); ..

Answer / susie

Answer :

Compiler error: Too many initializers

Explanation:

The array a is of size 4 but the string constant requires 6
bytes to get stored.

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C Code Interview Questions

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }

10 Answers  


Write a program that reads a dynamic array of 40 integers and displays only even integers

2 Answers  


write a program in c language to get the value of arroy keys pressed and display the message which arrow key is pressed?

1 Answers  


Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };

1 Answers  


main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }

1 Answers  


Who could write how to find a prime number in dynamic array?

1 Answers  


char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }

1 Answers  


main() { 41printf("%p",main); }8

1 Answers  


Write a routine to implement the polymarker function

1 Answers   TCS,


main() { int i=10; i=!i>14; Printf ("i=%d",i); }

1 Answers  


Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped

1 Answers   IBM,


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }

1 Answers  


Categories