Convert a letter into ASCII code

Hi, so I have this programming assignment and I've been stuck on this problem for quite some time, this is what I have so far. The question was to create a bar graph consisting of * for every number, so if they input a 9, then there should be 9 *. However, if they input a letter then the ascii code for the letter should appear.

//Declaration of Variables
int num1; //The first number they input
int num2; //The second number they input
int num3;
int num4;

//Input values

cout<<"Please input 4 digits or characters."<<endl;
cin>>num1>>num2>>num3>>num4;
cout<<num1<<": ";

if (isalpha(num1))
{
cout<<((int) num1);
}
else
{

for(int count=1;num1>=count;count++)
cout<<"*";
}
Clarification needed.....

Are you looking for one input or four inputs. If it is one, then what is the point of the variables num2, num3, and num4? If it is four, why are you only using num1?

Could you please give an example input and and output.

Thank you
so for example, if the user inputted 9432 then the bar graph should display

2 **
3 ***
4 ****
9 *********

but if the user inputs 9Aa2

2 **
a 97
A 65
9*********
I'd recommend you use an array, so that way you can easily loop through said array and check each element.
Topic archived. No new replies allowed.