#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; } |
chevron_right
filter_none
(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
Recommended Posts:
- C | Loops & Control Structure | Question 7
- C | Loops & Control Structure | Question 4
- C | Loops & Control Structure | Question 19
- C | Loops & Control Structure | Question 21
- C | Loops & Control Structure | Question 3
- C | Loops & Control Structure | Question 2
- C | Loops & Control Structure | Question 1
- C | Loops & Control Structure | Question 5
- C | Loops & Control Structure | Question 6
- C | Loops & Control Structure | Question 18
- C | Loops & Control Structure | Question 8
- C | Loops & Control Structure | Question 11
- C | Loops & Control Structure | Question 10
- C | Loops & Control Structure | Question 12
- C | Loops & Control Structure | Question 13



