C program to find day of given date using switch case
Answers
Answered by
4
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:.
If any case does not matches then, for default: case print "Invalid week number".
Similar questions