Here is a simple one line program using printf :
void main()
{
printf("%d%d",printf("Cis"),printf("good"));
}
Output :
goodCis34
How can this output be explained ??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The reason why
goodandCisare printed first is because the parameters need to be evaluated before the top-levelprintf()can be called.Then the return values are printed out.
Note that C does not specify the order of evaluation of the parameters. There are no sequence points within the statement. Therefore the order is undefined. And the result can appear in any order. (hence why they appear to be evaluated out-of-order in this case)