0

what is the output of this code?

printf(%d %d,printf("ayush"),printf("shalya"))

25th Aug 2020, 9:25 AM
Pro Ash
Pro Ash - avatar
3 ответов
+ 12
(E-R-R-O-R 🤪 in your case without terminating semi colon, proper quotes and so) EXPLANATION : So that's a nested printf in C. The compiler treats this printf("%d %d", printf("ayush"), printf("shalya")) ; like printf(("%d %d", (printf("ayush"), (printf("shalya") )))) ; ( I hope the Parenthesis are well paired) then the compiler starts executing from the innermost printf function that is printf("shalya") in our case and then printf("ayush") and so. Hence outputting shalya ayush. Now its the turn of outermost part[(("%d %d", (printf("ayush"), (printf("shalya") )))] to be executed. (On success the printf returns the total number of characters. On failure, a negative number is returned.) hence returning the length of shalya and ayush to %d. Hence we 5 and 6 in our case. (I hope I'm correct) Pro Ash https://code.sololearn.com/c0mR26RU4981/?ref=app
25th Aug 2020, 9:26 AM
minirkk
minirkk - avatar
+ 15
Post ur programming related queries not quizzes If you want to play quizzes , u can post this in ur post feed https://www.sololearn.com/discuss/1316935/?ref=app
25th Aug 2020, 9:28 AM
ÃKR
ÃKR - avatar
+ 7
Does that even exist? 🙄
25th Aug 2020, 9:27 AM
Nathaniel Temitope Ogunjobi
Nathaniel Temitope Ogunjobi - avatar