Strings - Find Output of Program :: Discussion


2.What will be the output of the program?
A.A
B.a
C.c
D.65
Answer:  Option  A
Explanation:

Step 1char p[] = "%d\n"; The variable p is declared as an array of characters and initialized with string "%d".

Step 2p[1] = 'c'; Here, we overwrite the second element of array p by 'c'. So array p becomes "%c".

Step 3printf(p, 65); becomes printf("%c", 65);

Therefore it prints the ASCII value of 65. The output is 'A'.

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers