Need to Insert Some Code To Check for Invalid Input

I need my program to let the user know if they had entered an invalid number, that would be any number that is not between 0 and 35 and for it to output something like: You entered an invalid value, run your program again.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

using namespace std;

int main()
{
	int num;

	cout << "Enter and number between 0 and 35.\n";
	cin >> num;

	if (num <= 9)
		cout << num << endl;
		
	else if (num >= 10)
		cout << static_cast<char>(num-10+'A') << endl;
		
	else if (num >=! 10)
		cout << "You have entered an invalid number.";
	
	return 0;
}
Topic archived. No new replies allowed.