IF ANYONE CAN HELP, I'D APPRECIATE IT!
How do I create a program that allows a user to put in two INT values such as:
Code:
cin >> int1 >> int2;
and then outputs ONLY the values between the two numbers they input that meet a certain restriction? For instance I'm trying to make a program where a person puts in two date ranges and it will diplay the LEAP YEARS within that range
Code:
example: cout << "the leap years were:" << int1 << through int2;
I cannot use pointers/arrays...I'm pretty much limited to loops, IF statements, switches, functions etc....
So far I've managed to create a program that shows if the values placed are LEAP YEARS (but it may not be perfect....), but the main issue is that it does NOT scan a RANGE of years at all.....I have to use at least 1 function and I'm using 2......
IF ANYONE CAN HELP, I'D APPRECIATE IT!
Code:
#include <iostream>
using namespace std;
int leapyears(int year1);
int leapyears2(int year2);
int main()
{
int year1;
int year2;
cout << "Enter a range of years to consider:";
cin >> year1 >> year2;
if ((year1 & year2) % 400 || 100 == 0)
leapyears(year1); leapyears2(year2);
}
int leapyears(int year1) //function ONE
{
switch (year1 % 4)
{
case 0:
if (year1 % 100 == 0)
{
cout;
if (year1 % 400 == 0)
{
cout << "The Leap years were: " << year1;
}
else
cout;
}
else
cout << "The Leap years were: " << year1; break;
//case 3:
// cout << "Next year is a leap year. "; // COMMENTED OUT FOR NOW
default:
return 0; break;
}
return year1;
}
int leapyears2(int year2) //function TWO
{
switch (year2 % 4)
{
case 0:
if (year2 % 100 == 0)
{
cout;
if (year2 % 400 == 0)
{
cout << " " << year2 <<"\n";
}
else
cout;
}
else
cout << " " << year2 <<"\n"; break;
//case 3:
//cout << "Next year is a leap year. "; // COMMENTED OUT FOR NOW
default:
return 0; break;
}
return year2;
}