What is wrong with my code?
//Ask user to input # of a num
//Check for legal input
//Print out:
//The name of the num is _____ .
Code:
#include
using namespace std;
int main()
{
int num;
cout<<"Please enter the number of a month: ";
cin>>num;
if ( (num < 1 ) || (num > 12) )
cout<<"That’s not the number of a month. "<<endl;
else
{
cout<<"The name of the month is: ";
if (num == 1)
cout<<"January";
else if (num == 2)
cout<<"February";
else if (num == 3)
cout<<"March";
else if (num == 4)
cout<<"April";
else if (num == 5)
cout<<"May";
else if (num == 6)
cout<<"June";
else if (num == 7)
cout<<"July";
else if (num == 8)
cout<<"August";
else if (num == 9)
cout<<"September";
else if (num == 10)
cout<<"October";
else if (num == 11)
cout<<"November";
else
cout<<"December";
cout<<"."<<endl;
}
return 0;
}
It will not execute. It is saying that I have one error.
[code][/code]tagged by Salem