Day#34 'C' Coding Challenge

Day#34 'C' Coding Challenge

What is the output of the below code?

#include <stdio.h> void main() { printf("%d", printf("%d", printf("%d", printf("%d", printf("%s", "TalentEve"))))); }

---------------------------------------------------------------

The code tests below scenarios:

1. What does printf return?
2. What does a printf print if there is a printf in the print statement

---------------------------------------------------------------

The return value of is the number of characters written. When we start from the right to left, first "TalentEve" shall be printed, coming the preceding printf it returns 9 as "TalentEve" has 9 characters. Then the preceding printf returns 1 as previously 9 was printed which is only 1 character. Then all the preceding printf statements also prints 1 as the other printf before it are printing only 1 character.

The output shall be TalentEve9111

Post a Comment

0 Comments