Open In App
Related Articles

Algorithms Quiz | SP2 Contest 1 | Question 4

Improve Article
Save Article
Like Article

What will be the output of the below C program?

#include <stdio.h>
int main()
    int x = 2;
        printf("%d", x);
    } while(--x <= 2);
    return 0;

(A) Runtime Error
(B) 2
(C) 3
(D) Infinite Loop

Answer: (D)

Explanation: As the value of x is incremented(++x) and then decremented(–x), hence no change in the value of x will occur and it will be as 2.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Last Updated : 28 Aug, 2018
Like Article
Save Article
Similar Reads