Problems with leap year loop.

I am supposed to make a program that shows all the leap years are between someone's birth year and the present time. With the current code, it starts at 824 no matter what number I input. Can someone please help?

#include <iostream>
using namespace std;
int main()
{
int year;
cout <<"Enter your year of birth." << endl;
cin >> year;
for (int year = 0; year <= 2012; year++)
if ((year % 400 == 0) || (year % 4 == 0))
cout <<year<< " is a leap year." << endl;


return 0;
}
Try this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;
int main()
{
   int year;
   cout <<"Enter your year of birth." << endl;
   cin >> year;

   for (int i = year; i <= 2012; i++)
   {
       if ((i % 400 == 0) || (i % 4 == 0))
       {
          cout << i << " is a leap year." << endl;
       }
   }

   return 0;
}
It worked! Thank you so much!
Topic archived. No new replies allowed.