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

Is it possible to type a name in command line without ant quotes?

1 Answers   Excel, Infosys,


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


what is brs test reply me email me kashifabbas514@gmail.com

0 Answers  


main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d \n”,a,*a,**a,***a); printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1); }

2 Answers  


Printf can be implemented by using __________ list.

3 Answers  






main() { int i=5,j=6,z; printf("%d",i+++j); }

2 Answers  


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

1 Answers  


main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


Which one is taking more time and why ? :/home/amaresh/Testing# cat time.c //#include <stdio.h> #define EOF -1 int main() { register int c; while ((c = getchar()) != EOF) { putchar(c); } return 0; } ------------------- WIth stdio.h:- :/home/amaresh/Testing# time ./time_header hi hi hru? hru? real 0 m4.202s user 0 m0.000s sys 0 m0.004s ------------------ Witout stdio.h and with #define EOF -1 =================== /home/amaresh/Testing# time ./time_EOF hi hi hru? hru? real 0 m4.805s user 0 m0.004s sys 0 m0.004s -- From above two case , why 2nd case is taking more time ?

0 Answers  


write a program to Insert in a sorted list

4 Answers   Microsoft,


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

2 Answers   HCL,


void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }

1 Answers  


Categories