Can anyone plzzz.... explain | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone plzzz.... explain

int i=1; printf ("%d",printf("%d", printf ("%d",i))); what is the answer and plzzz... explain and if u like plzzz...like 😎😍😚😚

14th Aug 2017, 9:15 PM
CHandan AGrawal
CHandan AGrawal - avatar
5 Answers
+ 5
In C and C++ the printf's return value is the outprinted number of characters, so the output is 1 and then 1 again and then 1 again so 111 will be printed on the console. :) Hopes it helped
14th Aug 2017, 9:24 PM
Hajnal Máté
Hajnal Máté - avatar
+ 2
Now the answer is 43 in the first iterate of printf (it's 2 chars) so the output of the second iterate is 2. So 432 will be written on the console :)
14th Aug 2017, 9:31 PM
Hajnal Máté
Hajnal Máté - avatar
+ 2
Because the number of characters in 43 is 2. Try to look for it like a string "43" as a string has 2 characters so 2 will be printed out in the end.
14th Aug 2017, 9:53 PM
Hajnal Máté
Hajnal Máté - avatar
+ 1
then what is the answer now int i=43; printf ("%d",printf("%d", i)); what is the answer and plzzz... explain
14th Aug 2017, 9:29 PM
CHandan AGrawal
CHandan AGrawal - avatar
0
no....dear now answer is 2 whyyyyy
14th Aug 2017, 9:51 PM
CHandan AGrawal
CHandan AGrawal - avatar