what will be printed by this printf?
printf("%c",printf("hi")["sharkselva"]));
}
Answer Posted / vadivelt
Ans: hia
Reason is, in the below statement,
printf("%c",printf("hi")["sharkselva"]));
printf("hi") shall be executed first. and this printf will
return the value 2. ie., no of characters successfully
printed by printf()statement.
So in runtime, "printf("%c",printf("hi")["sharkselva"]));"
will print "hi" and after, the main printf shall be
replaced as "printf("%c",2["sharkselva"]));".
According to printf() implementation, printf("%c",2
["sharkselva"]));" has to print the value at the array, for
the index given ie., 2. So in the array index '2',
character 'a' is available.
Now a is printed.
So the total output will be -> hia
| Is This Answer Correct ? | 31 Yes | 1 No |
Post New Answer View All Answers
What are keywords in c with examples?
Explain the difference between null pointer and void pointer.
What is getch?
What should malloc(0) do?
What is bubble sort technique in c?
With the help of using classes, write a program to add two numbers.
What is the use of typedef in structure in c?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
What does s c mean on snapchat?
What is difference between structure and union in c programming?
What is bubble sort in c?
why wipro wase
Is there any possibility to create customized header file with c programming language?
What is graph in c?
Explain the use of #pragma exit?