I don't like having a lot of if-statements. Is there anyway that make an If-statement that allows the int to be equal to multiple numbers and then execute the statement if any one of those numbers are entered?
#include <iostream>
using namespace std;
int main()
{
int year;
cin>>year;
//Rat
if (year==2006)
cout<<"The year "<< year <<" is the year of the Rat";
if (year==1994)
cout<<"The year "<< year <<" is the year of the Rat";
if (year==1982)
cout<<"The year "<< year <<" is the year of the Rat";
if (year==1970)
cout<<"The year "<< year <<" is the year of the Rat";
//Ox
if (year==)
//Error message
if (year<1964)
cout<<"Please enter a valid number.";
if (year>2018)
cout<<"Please enter a valid number.";
return 0;
}
Aucun commentaire:
Enregistrer un commentaire