The Gateway to Computer Science Excellence
+1 vote
779 views

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. ABCDEFGH1000
  2. CDEFGH1000
  3. DDEFGHH1000
  4. DEFGH1000
in Programming by Veteran (105k points)
recategorized by | 779 views

3 Answers

+1 vote
Best answer

Ans is D

printf("%C", *(&S[3])); = D
        printf("%s", S+4); = EFGH
        printf("%u", S); = 1000
by Veteran (63k points)
selected by
0 votes
Ans is DEFGH1000 none of the option matches...
by Boss (25.6k points)
0 votes

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.

by Active (1.9k points)
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,291 answers
198,210 comments
104,902 users