Difficulty: Easy
Correct Answer: 1, 3, 5
Explanation:
Introduction / Context:This conceptual item asks you to pick the accurate descriptions of several C# control-flow constructs: switch, jump statements (break/continue/goto/return), and the do loop. The distractors intentionally conflate goto and continue behaviors with switch case labels.
Given Data / Assumptions:
Concept / Approach:Recall: switch selects among cases; jump statements cause immediate transfers of control; continue skips to the next iteration of the current loop, not to a switch label; the do statement executes the body at least once, then repeats until the expression becomes false.
Step-by-Step Solution:
1) Correct — switch handles multiple selections via case labels (and can be used with enums). 2) Incorrect — goto does not inherently “go to next iteration”; that is continue. Plain goto transfers to a label. 3) Correct — break/continue/goto/return are jump statements that transfer control immediately. 4) Incorrect — continue does not target switch labels; use goto case/goto default within switch. 5) Correct — do { ... } while (expr); repeats until expr evaluates to false.Verification / Alternative check:Write micro-examples using each construct and observe the control flow in a debugger; the behaviors align with the reasoning above.
Why Other Options Are Wrong:
Common Pitfalls:Assuming continue can send control into arbitrary labels or switch cases; misunderstanding that do executes once before the first test.
Final Answer:1, 3, 5
float a = 0.7;, what will this program print and why?
#includefor loop in C. What does this program print?
#includeswitch statement in C? Note the statement before any case label.
#include
Discussion & Comments