write a program using switch statement to print days of the week
Answers
Answer:
Skip to content
Search for:
C program to print day of week name using switch case
June 3, 2015PankajC programmingC, Program, Switch
Write a C program to input week number(1-7) and print day of week name using switch case. C program to find week day name using switch case. How to find day name of week using switch case in C programming.
Example
Input
Input week number(1-7): 2
Output
Tuesday
Required knowledge
Basic C programming, Switch case statement
Logic to print day of week name using switch...case
Step by step descriptive logic to print day name of week.
Input day number from user. Store it in some variable say week.
Switch the value of week i.e. use switch(week) and match with cases.
There can be 7 possible values(choices) of week i.e. 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:.