Leap Years
Def: A year is a century year if it is divisible by 100.
Def: A year is a non-century year if it is not a century year.
Def: A year is a leap year if it is a non-century year that is divisible by 4, or a century year that is divisible by 400. Nothing else is a leap year.
In a source file named leapyears.cpp, write a program that will prompt the user for the starting year and ending year for a range of years and print to the screen all leap years in that range, 5 years per line. You must write a separate function called isLeapYear that takes a year as a parameter and returns whether or not that year is a leap year. Your main function will call the isLeapYear function in a loop for every year within the range delineated by, and including, the starting and ending years.
#include <iostream>
using namespace std;
bool LeapYear(int y)
{
return ( y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0);
}
double isLeapYear(double x)
{
if( x > -10000 && x < 10000)
return x;
}
int main()
{
int x;
cout << "Please enter start and end of a range of years: ";
cin >> x;
if (isLeapYear(x))
{
if (LeapYear(x))
cout << x;
}
}
that's what i have, any ideas how to fix it?
thanks!