Skip to content
Related Articles

Related Articles

UGC-NET | UGC NET CS 2015 Jun – II | Question 11
  • Last Updated : 14 May, 2018

What is the output of the following program?
(Assume that the appropriate preprocessor directives 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 */        
     }

(A) ABCDEFGH1000
(B) CDEFGH1000
(C) DDEFGHH1000
(D) DEFGH1000


Answer: (D)

Explanation:

main ( ) 
     { char S[ ] = "ABCDEFGH"; 
      printf ("%C", *(&S[3]));
      printf ("%s", S + 4); 
      printf ("%u", S);        
      /* Base address of S is 1000 */        
     }

From above program:
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.


Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :