C | Operators | Question 27

Predict the output of following C program

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
int main()
{
    int i = 0;
    do
    {
        printf("GeeqsQuiz ");
        i = i++;
    }
    while (i < 5);
    return 0;
}

chevron_right


(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


Article Tags :
Practice Tags :


Be the First to upvote.


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