Choosing A Number Between Limits

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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>

using namespace 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 . . .

*/
Last edited on
closed account (Dy7SLyTq)
you need &&
-_____________- Thank you kind soul.
Topic archived. No new replies allowed.