I don't know whats wrong with this code. Im trying to choose a # between 1 and 1000 (can be 1 or 1000), error check it, but keep asking until I get the correct input. Help!
#include<iostream>
usingnamespace std;
int main ()
{
int num;
bool goodNum;
goodNum = false;
while (!goodNum)
{
cout << "Enter a number between 1 and 1000 then hit enter: ";
cin >> num;
cout << endl;
if (num>=1 || num<=1000)
{
cout << "You entered " << num << "." << endl;
goodNum = true;
}
else
cout << "Enter a number between 1 and 1000. Try again." << endl;
}
system ("pause");
return 0;
}
/*
This program analyzes a number, determining whether a number is prime or not, pe
rfect or not, and output a list of all divisors for non-prime and perfect numbe
rs.
Enter a number between 1 and 1000 then hit enter: 9000
You entered 9000.
Press any key to continue . . .
*/