0 votes 0 votes WHAT IS THE OUTPUT OF THE FOLLOWING CODE? printf("%d",printf("ABC")); IS IT ABC3 Deepanshu asked Sep 5, 2018 Deepanshu 1.3k views answer comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments Mizuki commented Sep 5, 2018 reply Follow Share No,read the syntax of scanf(), it is int scanf(const char *format, ...); and it's first argument is of const char* type i.e scanf() expects 1st argument as of const char* and 1st argument provided is "ABC" which is of char* type though you should provide some format specifier like %s etc. 0 votes 0 votes Mizuki commented Sep 5, 2018 reply Follow Share EOF is returned since there is a matching failure. 0 votes 0 votes srestha commented Sep 6, 2018 reply Follow Share but %s also not giving correct output. why? https://ideone.com/RAGKnS 1 votes 1 votes Please log in or register to add a comment.
Best answer 3 votes 3 votes The return value of printf is the number of characters it printed. printf("%d",printf("ABC")); To execute the outer printf it needs to execute the inner printf to obtain the second parameter. Hence output is ABC3 sakharam answered Sep 5, 2018 selected Sep 6, 2018 by srestha sakharam comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments !KARAN commented Sep 5, 2018 reply Follow Share $\text{It will not print anything as we have not specified any format specifier}$ 0 votes 0 votes sakharam commented Sep 5, 2018 reply Follow Share @!KARAN it prints return value of scanf 0 votes 0 votes Rustam Ali commented Sep 5, 2018 reply Follow Share printf("%s",scanf("ABC")); printf("%c",scanf("ABC")); @srestha try this!! 0 votes 0 votes Please log in or register to add a comment.