in Programming recategorized by
243 views
0 votes
0 votes
#include<stdio.h>

Int main(void){

Int a=printf("%d",printf("%d %d",printf("GATE"),printf("OVERFLOW")));

printf("%d",a);

return 0;

}

What is the reason for different output?

Explain ideas.
in Programming recategorized by
243 views

4 Comments

I thought “order of evaluation of parameters of function is not standard in C” → order of evaluation of parameters of function depends on compiler , in some compiler evaluation will be right to left and in some left to right. but it may be wrong.

 You are saying it can be something else including these two cases. right?

0
0
f(A,B,C) function with three parameters, then there are 3! =6 orders possible for evaluation
1
1
got it sir ...thanks 😍
0
0

1 Answer

1 vote
1 vote

Keypoints:

  • printf returns the number of characters printed.
  • printf will consider the 2nd argument only if the first argument is a format specifier.

Now, there are 4 printfs in the initialisation line, lets number each one 1,2,3,4 and analyze.

3rd and 4th printf outputs 4 and 8 which results in 2nd printf arguments as printf(“4 8”);

this will output 3.

1st printf will have args as printf(“3”);

which outputs 1, which gets stored in “a” and is printed in the next line.