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

#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above

2 Answers   HCL,


int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“bye”);} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }

1 Answers  


Sir... please give some important coding questions asked by product companies..

0 Answers  


WAP to display 1,2,3,4,5........N

2 Answers  






main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]); }

2 Answers  


Write a procedure to implement highlight as a blinking operation

2 Answers  


What is the hidden bug with the following statement? assert(val++ != 0);

1 Answers  


/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }

4 Answers  


main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }

1 Answers  


main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }

1 Answers  


Write a program to print a square of size 5 by using the character S.

6 Answers   Microsoft,


Categories