07:59 -
OOPS using C++
No comments
Using switch statement write a program in C++ to print the month of a year.
/*Program to print the month of a year*/
#include<iostream.h>
void main()
{
int month;
char
monthName[15];
cout<<”Enter month number : “<<endl;
cin>>month;
switch (month)
{
case 1:
montName=”January”
break;
case 2:
montName=”February”
break;
case 3:
montName=”March”
break;
case 4:
montName=”April”
break;
case 5:
montName=”May”
break;
case 6:
montName=”June”
break;
case 7:
montName=”July”
break;
case 8:
montName=”August”
break;
case 9:
montName=”September”
break;
case 10:
montName=”October”
break;
case 11:
montName=”November”
break;
case 12:
montName=”December”
break;
default:
cout<<”Please Enter Correct
Month number between 1 to 12”;
}/*End
of switch statement*/
cout<<”The
month for the month number”<<month<<” is : “<<monthName;
}/*End of main() function*/
0 comments:
Post a Comment