QuestionQ19

Using Operators and Decision Constructs

Given this code fragment:

Question Image

What is the output?

  • A 3
  • B 4
  • C -1
  • D Compilation fails.
Explanation

A switch case continues into the following case unless it encounters break. Processing "mon" increments the value and falls through to the "wed" case, while "sun" and "sat" each decrement it. The final value printed is 3.

Community Discussion

No comments yet. Be the first to start the discussion!