"We cannot solve our problems with the same thinking we used when we created them."
- Albert Einstein
What will be the output of the program ?
char p = "%d\n";
p = 'c';
Option Answer: E
Step 1: char p = "%d\n"; The variable p is declared as an array of characters and initialized with string "%d".
Step 2: p = 'c'; Here, we overwrite the second element of array p by 'c'. So array p becomes "%c".
Step 3: printf(p, 65); becomes printf("%c", 65);
Therefore it prints the ASCII value of 65. The output is 'A'.
(Tue, May 29, 2012 03:54:40 PM)
How p becomes %c in the last printf statement?
(Mon, Nov 12, 2012 05:38:38 PM)
char p is an array that having each array value.
then p=d=c and printf("%d\n",65);
printf will change to printf("%c\n",65);
Now printf can print only character value(as of %c) finally print ASCII value of 65=A.
Write your comments here: