Write a program to display names of days in a week using switch case
Answers
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 Program in Switch Case :
#include <iostream>
using namespace std ;
int main ( )
{
char ch ;
cout <<"Enter 1,2,3,4,5,6,7 : " ;
cin >> ch ;
switch ( ch )
{
Case 1 : cout<< "Sunday " ;
break ;
Case 2 : cout<< " Monday " ;
break ;
Case 3 : cout<< " Tuesday " ;
break ;
Case 4 : cout<< " Wednesday " ;
break ;
Case 5 : cout<< " Thursday" ;
break ;
Case 6 : cout<< " Friday " ;
break ;
Case 7 : cout<< " Saturday " ;
break ;
default :cout <<invalid input !! " ;
}
return 0 ;
}