program to print day of week using switch statement

Hello friends, in this example, you will learn how to print day of week using switch statement in C programming language using following topics:
Print day of week
  1. Data Types 
  2. Variables And Constants
  3. Conditions Statements
  4. Loops


Enter Number of day: 5

Explaination Of Program:

  • Input day number from user, Store it in variable 'day'
  • Switch the value of 'day', use switch(day).
  • There can be 7 possible attempt of day, from 1 to 7. Therefore write 7 case inside switch. In addition, add default case as an else block.
  • For case 1: print "MONDAY", 
  • For case 2: print "TUESDAY" and so on. 
  • Print "SUNDAY" for case 7.
  • If any case does not matches then, for default: case print "Invalid Input".

Post a comment