in Programming edited by
1 vote
1 vote

What is the output of the following program: (Assume that the appropriate preprocessor directives are included and there is not syntax error)

main( )
    {   char S[]="ABCDEFGH";
        printf("%C", *(&S[3]));
        printf("%s", S+4);
        printf("%u", S);
    /*Base address of S is 1000 */
  1. $\text{ABCDEFGH}1000$
  2. $\text{CDEFGH}1000$
  3. $\text{DDEFGHH}1000$
  4. $\text{DEFGH}1000$
in Programming edited by

3 Answers

1 vote
1 vote
Best answer

Ans is D

printf("%C", *(&S[3])); = D
        printf("%s", S+4); = EFGH
        printf("%u", S); = 1000
selected by
1 vote
1 vote
Ans is DEFGH1000 none of the option matches...
1 vote
1 vote

printf (“%C”, *(&S[3])); will print character at *(&S[3]) i.e. D.
printf (“%s”, S + 4); will print string starting from S + 4 i.e. EFGH.
printf (“%u”, S); will print address of S i.e. 1000.
Since there is no new line instruction, So DEFGH1000 will be the output.
So, option (D) is correct.


Related questions