C Program#182 – To Display Working Days and Week-End Days (switch statement).

Program to Display Working Days and Week-End Days (switch statement).:

Program Logic. :

  • switch statement permits to associate same block for multiple cases, thus we can take advantage of it.
  • First, take input of day of week (1 to 7) in an integer variable.
  • Use, day variable as switch variable.
  • Define case 2:,case 3,…to case 6: with single associated block, display “Working Day”.
  • Define case 1: and case 7: (for sunday and saturday respectively) with another block, display “Weekend Day”.
  • At last, define default: block, display “Invalid Input” message.
  • Still not understood ? See the proper working example in action below.

Full Well Commented, Self-Explanatory Example Program of the same given below.

Below Here are Three (3) different Outputs of the program.

Output of the Program (Run 1 ):

Output of the Program (Run 2 ):

Output of the Program (Run 3 ):

Output of the Program (Run 4 ):

Output of the Program (Run 5 ):