Important MCQ

An else is matched with

Q.An else is matched with

A) the last if of the program
B) no if
C) the nearest preceding unmatched if
D) the first if of the program
Correct Answer:
Option C
Detailed Explanation:
C) the nearest preceding unmatched if is correct. A nested if is an if statement inside another if. The inner condition is reached only if execution enters the outer block; braces and indentation make the structure clear.