VKV SirTest Lab

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

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

  1. 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.

  2. 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.

  3. Keyword to exit a switch is:

    Options: A) exit   B) stop   C) return only   D) break

    Answer: D) break. break ends switch.

Take a free Nested If-Else and Switch test

All units of Computer Programming Lab (C)