Important MCQ

Which is the correct form?

Q.Which is the correct form?

A) if (x>0) {...} else (x<=0) {...}
B) if (x>0) else {...}
C) if (x>0) {...} else {...}
D) if x>0 {...} else {...}
Correct Answer:
Option C
Detailed Explanation:
C) if (x>0) {...} else {...} is correct. An if-else statement makes a two-way decision: the if block runs when the condition is true, otherwise the else block runs. Exactly one branch is selected.