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
which type of aspect you want from the student.
how do you programme Carrier Sense Multiple Access
Difference between pass by reference and pass by value?
What is 'bus error'?
Why doesnt the call scanf work?
What is the general form of a C program?
What is chain pointer in c?
What is the -> in c?
Does sprintf put null character?
What is function what are the types of function?
Ow can I insert or delete a line (or record) in the middle of a file?
Explain what is the difference between text files and binary files?
Write a program to check palindrome number in c programming?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
How many identifiers are there in c?