I have a problem which is directing to me to write a program that prompts the user to input an integer from 0-35.
If the int is <= 9 it simply outputs the integer. I'm good on this part.
This is where i'm struggling. Any integer >=10 it wants me to output as for example A..10 B..11 C..12 all the way through Z.. 35.
Whenever I run my program I only get weird symbols. I'm a first time C++ beginner, at the moment we are only using the if and else statements in our programs. I know nothing about classes and only use the main() function at the moment.
When I run my program this is my output:
Please enter an integer between 0 and 35: 20
The value of (variable x) currently is: ΒΆ20
Press any key to continue . . .
This is my current source code:
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Please enter an integer between 0 and 35: ";
cin >> x;
if (x <= 9)
{
cout << "You entered " << x << endl;
cout << endl;
}
else if (x >= 10)
{
cout << "The value of (variable x) currently is: "
cout << static_cast<char>(x) << x << endl;
}
return 0;
}
I've tried making a char variable and subtracting the ascii values then adding the difference etc but i'm still getting no where. Was wondering if anyone could throw me a couple of hints, thanks.