Thursday 18 April 2013

printf("%d",printf("%s",str));


What will be output if you will compile and execute the following c code?

void main(){
   char *str="Hello world";
   printf("%d",printf("%s",str));
}


(A) 11Hello world

(B) 10Hello world

(C) Hello world10

(D) Hello world11

(E) Compiler error


________________________________________
Explanation:
Return type of printf function is integer and value of this integer is exactly equal to number of character including white space printf function prints. So, printf(“Hello world”) will return 11.

No comments:

Post a Comment