Close
Close

Why does a print statement inside print statement print the statement as well as the number of letters?

   mohsin.ms

code

#include <stdio.h>

int main(void)

{

printf("%d",printf("hello"));

return 0;

}

 


Answers

  •   

    printf function returns an integer that is the total numbers of characters printed by the function.

    In your program, the inner printf function prints the string hello and returns the number of characters printed i.e. 5. Then the outer printf function prints this integer 5. Therefore, the overall output is hello5.



Ask Yours
Post Yours
Write your answer