> Explain output plz.?

Explain output plz.?

Posted at: 2014-12-18 
include

int main()

{

printf("%d\n ",printf("%d\n ",printf("%d\n",printf("SAURABH chinna ram hajibasha"))));

}

This is a terrible, useless question. Whoever nests printf calls should be shot.

Anyways: the only relevant passage from the standard's passage on evaluation order:

When calling a function (whether or not the function is inline, and whether or not explicit function call syntax is used), every value computation and side effect associated with any argument expression, or with the postfix expression designating the called function, is sequenced before execution of every expression or statement in the body of the called function.

--

From the reference referring to the return-value of printf:

On success, the total number of characters written is returned.

If a writing error occurs, the error indicator (ferror) is set and a negative number is returned.

If a multibyte character encoding error occurs while writing wide characters, errno is set to EILSEQ and a negative number is returned.

So, the subexpressions nested in the outermost call to printf are evaluated from the inside out.

This should print

SAURABH chinna ram hajibasha, which is the side effect of the innermost evaluation of printf. This is

Followed immediately by the number of characters output, or a negative number if it fails, and a newline character, The side effect of the 3rd nested call. This repeats for the 2nd and outermost call.

#include

int main()

{

printf("%d\n ",printf("%d\n ",printf("%d\n",printf("SAURABH chinna ram hajibasha"))));

}