Skip to content
Related Articles

Related Articles

Improve Article

C | Operators | Question 27

  • Difficulty Level : Hard
  • Last Updated : 28 Jun, 2021

Predict the output of following C program

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.




#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

My Personal Notes arrow_drop_up
Recommended Articles
Page :