recategorized by
443 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.
recategorized by

1 Answer

1 votes
1 votes

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.

Related questions