Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 36: Write a C++ program to read any month number in integer and print the no of days for this month.

#include<iostream>
using namespace std;

int main()
{
	int n;
	cout<<"\nenter the no of month (1-january) : ";
	cin>>n;
	cout<<"\ntotal no of days in this month : ";

	if(n==2)
		cout<<"28";
	else if(n<8)
	{
		if(n%2==0)
		cout<<"30";
		else
		cout<<"31";
	}
	else
	{
		if(n%2==0)
		cout<<"31";
		else
		cout<<"30";
	}
	return 0;
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.