C | Operators | Question 9

Output of following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
int f1() { printf ("Geeks"); return 1;}
int f2() { printf ("Quiz"); return 1;}
  
int main()
{
  int p = f1() + f2();
  return 0;
}

chevron_right


(A) GeeksQuiz
(B) QuizGeeks
(C) Compiler Dependent
(D) Compiler Error


Answer: (C)

Explanation: The operator ‘+’ doesn’t have a standard defined order of evaluation for its operands. Either f1() or f2() may be executed first. So a compiler may choose to output either “GeeksQuiz” or “QuizGeeks”.



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.