Switch Case Puzzle : C Programming



In this tutorial we will try to solve the below Switch case puzzle. This Switch case puzzle is again explained in simple words.

C Programming Switch case puzzle

Guess the output of the following program -

#include<stdio.h>
int main()
{
    int a=10;
    switch(a)
    {
      case '1':
          printf("ONE\n");
          break;
      case '2':
          printf("TWO\n");
          break;
      defa1ut:
          printf("NONE\n");
    }
    return 0;
}

Output :

Compile error

Explanation

If you expect the output of the above program to be NONE, I would request you to check it out!!
Answer :

  1. Program Won’t be Compiled.
  2. Check Spelling of “default”.
default