Stuck in an infinite while loop. Help.
Code:
#include <iostream.h>
#include <conio.h>
int main(){
int firstyer = 0;
cout<< "Enter -1 to stop program ";
cin>>firstyer;
while (firstyer != -1)
if (firstyer==1600|| firstyer == 2000||firstyer== 1756||firstyer ==1832||firstyer==544||firstyer == 3380)
{
cout<<"The year is a leap year"<<endl;
}
else if (firstyer==1700 || firstyer == 2033||firstyer==1962)
{
cout<< "The year is not a leap year"<<endl ;
}
else
{
cout<< "Number not applicable, enter a valid year. 1600, 1700, 2000, 1756, 2033, 1962, 1832, 544, 3380 only"<<endl;
}
cout<< "Enter -1 to stop program ";
cin>>firstyer;
getch();
return 0;
}
I get an infinite message after one of the IFs is true. I need it to repeat the loop by asking to enter a new number after one of the IF statements is true until -1 is entered.