VOOZH about

URL: https://www.geeksforgeeks.org/c/output-c-programs-set-30-switch-case/

⇱ Output of C programs | Set 30 (Switch Case) - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 30 (Switch Case)

Last Updated : 23 Jul, 2025
Prerequisite - Switch Case in C/C++

Interesting Problems of Switch statement in C/C++

  1. Program 1 Output:
    Default: 
    Explanation: In switch, an expression "num+2" where num value is 2 and after addition the expression result is 4. Since there is no case defined with value 4 the default case got executed.
  2. Program 2 Output:
    Bahubali
    Explanation: We can write case statement in any order including the default case. That default case may be first case, last case or in between the any case in the switch case statement. The value of expression "movie << (2 + movie)" is 8.
  3. Program 3 Output:
    XYZ
    Explanation: In C, comma is also operator with least precedence. So if x = (a, b); Then x = b Note: Case expression can be macro constant.
  4. Program 4
Output:
GEEKSFOR
Explanation: It is possible to write label of goto statement in the case of switch case statement. This article is contributed by Mr. Somesh Awasthi.
Comment
Article Tags:
Article Tags: