I'm using Dev-C++ on Windows. I'm trying to "Write a program that prompts the user to input an integer between 0 and 35. If the number is less than or equal to 9, the program should output the number; otherwise, it should output A for 10, B for 11, C for 12, ..., and Z for 35. (Hint: Use the cast operator, static_cast<char>() for numbers >= 10."
The program compiles, but when I run it, the command window closes right after I enter an integer. Please tell me what I have to add to my code to get it working.
using namespace std;
cout << "Enter a number between 0 and 35: ";
cin >> num;
cout << endl;
if (num <= 9)
cout << num << endl;
else if (num >= 10 && num <= 35)
cout << static_cast<char>('A' + (num - 10)) << endl;
else if (num < 0 || num > 35)
cout << "You have entered an incompatible number." << endl;