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

main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1)))); } } a. 512, 256, 128, 64, 32 b. 256, 128, 64, 32, 16 c. 128, 64, 32, 16, 8 d. 64, 32, 16, 8, 4

2 Answers   HCL,


Write a routine to implement the polymarker function

0 Answers   TCS,


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

2 Answers  


plz send me all data structure related programs

2 Answers  


Find the largest number in a binary tree

7 Answers   Infosys,






main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

4 Answers   HCL,


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

1 Answers  


main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

1 Answers  


int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

1 Answers  


void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(ā€œ%dā€,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(ā€œ%dā€,*cptr); }

1 Answers  


what is the code of the output of print the 10 fibonacci number series

2 Answers  


#include<stdio.h> int main() { int a=3,post,pre; post= a++ * a++ * a++; a=3; pre= ++a * ++a * ++a; printf("post=%d pre=%d",post,pre); return 0; }

3 Answers  


Categories