Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C | Loops & Control Structure | Question 20

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article




#include <stdio.h>
int main()
{
    int x = 3;
    if (x == 2); x = 0;
    if (x == 3) x++;
    else x += 2;
  
    printf("x = %d", x);
  
    return 0;
}

(A) x = 4
(B) x = 2
(C) Compiler Error
(D) x = 0


Answer: (B)

Explanation: Value of x would be 2. Note the semicolon after first if statement. x becomes 0 after the first if statement. So control goes to else part of second if else statement.

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads