Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
#include <iostream>
#include <iomanip>
using namespace std;


int main()


{

	int year;
	int leapyear;
	int month;
	int output_month;
	
	


cout << "Calendar Program for Spain " << endl << endl;
cout << "Please enter the year: ";
cin >> year;
	}
	return 0;
	
	
int month()
	{



	if (month ==1)
		cout<< "The month is January";
	else if (month==2)
		cout<< "The month is February";
	else if (month==3)
		cout<<"The month is March";
	else if (month==4)
		cout<<"The month is April";
	else if (month==5)
		cout<<"The month is May";
	else if (month==6)
                cout<<"The month is June";
	else if (month==7)
		cout<<"The month is July";
	else if (month==8)
		cout<<"The month is August";
	else if (month==9)
		cout<<"The month is September";
	else if (month==10)
		cout<<"The month is October";
	else if (month==11)
		cout<<"The month is November";
	else if (month==12)
		cout<<"The month is December";
	else 
		cout<<" number must be between  1-12.";
	

int days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int leapyear()


if(year%400 ==0 || (year%100 != 0 && year%4 == 0))
    {
    
        isleapyear=true;
    
    else
    
        isleapyear=false;
		
	}

output_month()

	
	cout << "\n February     Sun  Mon  Tue  Wed  Thu  Fri  Sat\n";
}		}

return 0;</iomanip></iostream>


( copied from comment: )
Write a program, that incorporates a function called no_in_month that will return the number of days (an int not a string) in the month of February. The year is input by the user in main() and passed to the function when it is called. A leap year (29 days in February) occurs if the year is evenly divisible by 4. However, leap years do not occur at the end of centuries which are not evenly divisible by 400, e.g. the years 1700, 1800, 1900 are not leap years but 1600, 2000 are. that question
Posted
Updated 23-Feb-15 21:23pm
v5
Comments
Member 11469075 23-Feb-15 16:19pm    
im new to c++ any help on how to output month in leap year
Sergey Alexandrovich Kryukov 23-Feb-15 16:53pm    
This is a very bad question, not really a question, but the code dump (or a very, unacceptably dirty code), nothing explained...
This time, I formatted code for you, click "Improve question" to see how you will need to do it next time.
—SA
Member 11469075 23-Feb-15 17:16pm    
Write a program, that incorporates a function called no_in_month that will return the
number of days (an int not a string) in the month of February. The year is input by the
user in main() and passed to the function when it is called. A leap year (29 days in
February) occurs if the year is evenly divisible by 4. However, leap years do not occur at
the end of centuries which are not evenly divisible by 400, e.g. the years 1700, 1800,
1900 are not leap years but 1600, 2000 are. that question
Stefan_Lang 24-Feb-15 3:24am    
I added that info in the original question. Please, next time do that yourself. You can modify your question by clicking on the green [Improve Question] link at the bottom right of your question.

1 solution

Your code contains a lot of stuff that isn't related to the task you have been given. It does however miss a lot of other things that you have been asked to include:

1. "a function called no_in_month that will return the number of days (an int not a string) in the month of Februar"

2. "The year is input by the user in main()" (you need to add code that reads the year from standard input)

3. Also, while not explicitely stated, you should output the number of days in february as computed in no_in_month

Printing an entire calender for a given year doesn't appear to be part of your assignment.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900