98 928
Assignments Done
98.6%
Successfully Done
In April 2021

# Answer to Question #4690 in C++ for sathi

Question #4690
Problem Statement: You are required to write a program that prompts the user to enter the month and year, and displays the number of days in that particular month. For example, if the user entered month 2 and year 2000, the program should display that February 2000 has 29 days. If the user entered month 3 and year 2005, the program should display that March 2005 has 31 days.
1
2011-10-20T08:31:58-0400
#include <cstdlib>
#include <iostream>

using namespace std;
int mounth,year;
int main(int argc, char *argv[])
{
cout<<"enter month number : ";
cin>>mounth;
cout<<"enter year number : ";
cin>>year;
switch (mounth){
case 1:
& cout<<"January "<<year<<" has 31 days"<<endl;
& break;
case 2:
& if (year%4==0) cout<<"February "<<year<<" has 29 days"<<endl;
& else cout<<"January "<<year<<" has 28 days"<<endl;
& break;
case 3:
& cout<<"March "<<year<<" has 31 days"<<endl;
& break;
case 4:
& cout<<"April "<<year<<" has 30 days"<<endl;
& break;
case 5:
& cout<<"May "<<year<<" has 31 days"<<endl;
& break; &
case 6:
& cout<<"June "<<year<<" has 30 days"<<endl;
& break; &
case 7:
& cout<<"July "<<year<<" has 31 days"<<endl;
& break; &
case 8:
& cout<<"August "<<year<<" has 31 days"<<endl;
& break;
case 9:
& cout<<"September "<<year<<" has 30 days"<<endl;
& break;
case 10:
& cout<<"October "<<year<<" has 31 days"<<endl;
& break; &
case 11:
& cout<<"November "<<year<<" has 30 days"<<endl;
& break;
case 12:
& cout<<"December "<<year<<" has 31 days"<<endl;
& break;
default:
& cout<<"invalid month"<<endl;
& break;
}

system("PAUSE");
return EXIT_SUCCESS;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Assignment Expert
21.10.11, 16:30

We are pleased to assist you

shakthivelan
21.10.11, 04:54

thanks a lot. super