what will be printed by this printf?
printf("%c",printf("hi")["sharkselva"]));
}
Answers were Sorted based on User's Feedback
Answer / 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 |
What is calloc()?
#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Tell me a C program to display the following Output? 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
How many bytes are occupied by near, far and huge pointers (dos)?
who is the father of c
main() { printf("hello%d",print("QUARK test?")); }
can we write a c program with out using main
Is main is a keyword in c?
How can I sort a linked list?
How can I make a program in c to print 'Hello' without using semicolon in the code?
9 Answers C DAC, Practical Viva Questions,
what is the flow of execution in cprogram? ex:printf();,scanf();
What is meant by 'bit masking'?