Nested If-Else and Switch: viva questions and MCQs
Computer Programming Lab (C), Unit 3. 100+ Nested If-Else and Switch questions with explanations (Computer Programming Lab (C)). Topics: C Switch, C Switch Output, C Ifelse Output. Take a free…
Topics
- C Switch: decision, switch, labels, default, control, ladder, missing, placed
- C Switch Output: default printf, break default, invalid prints, printf invalid, switch, printf weekend, weekend prints
- C Ifelse Output: else printf, else scalene, equilateral else, isosceles else, leap year, scalene prints, year rule, program
Key terms: decision, switch, labels, default, control, ladder, default printf, break default, invalid prints, printf invalid, printf weekend, else printf, else scalene, equilateral else, isosceles else, leap year, scalene prints
Sample questions with answers
In C decision making, "Boolean value in C" means:
Options: A) Zero means false and any non-zero value means true B) Constant value in a switch that marks an entry point C) An if statement placed inside another if or else block D) ?: operator that returns one of two values
Answer: A) Zero means false and any non-zero value means true. Boolean value in C: Zero means false and any non-zero value means true.
In C decision making, "Dangling else" means:
Options: A) <, >, <=, >=, == and != used to compare values B) Execution continuing into the next case when break is missing C) Statement that selects which code runs based on a condition D) Ambiguity resolved by pairing else with the nearest if
Answer: D) Ambiguity resolved by pairing else with the nearest if. Dangling else: Ambiguity resolved by pairing else with the nearest if.
Keyword to exit a switch is:
Options: A) exit B) stop C) return only D) break
Answer: D) break. break ends switch.