C | Operators | Question 27
Predict the output of following C program
#include <stdio.h> int main() { int i = 0; do { printf ( "GeeqsQuiz " ); i = i++; } while (i < 5); return 0; } |
(A) GeeqsQuiz GeeqsQuiz GeeqsQuiz GeeqsQuiz GeeqsQuiz
(B) Infinite time GeeksQuiz
(C) Undefined Behavior
Answer: (C)
Explanation: The below statement causes undefined behavior.
i = i++;
See https://www.geeksforgeeks.org/sequence-points-in-c-set-1/ for details.
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.