What is the output of the following program? (Assume that the appropriate directive are included and there is no syntax error)
What is the output of the following program? (Assume that the appropriate directive are included and there is no syntax error)
main ()
{ char S[ ] = "ABCDEFGH",
printf ("%C", * (&S[3]));
printf ("%s", S + 4);
printf ("%u", S);
/* Base address of S is 1000*/ }
Show answerHide answer
Correct answer: (D) DEFGH1000
Explanation
S occupies addresses 1000 to 1008: A B C D E F G H \0. S[3] is 'D', and *(&S[3]) is 'D' itself, so %c prints D. S + 4 skips 4 characters, so %s prints "EFGH". %u prints the base address of S, 1000. Final output: DEFGH1000.