Show out the decimal,octal,and hexadecimal values

Hi,if got anyone can help me for this question pls give me some idea.Thank you.
This is the question.
Write a program that print the decimal,octal,and hexadecimal values of all characters between the start and stop characters entered by a user.For example, if the user enters an A and J,the program should print the all the character between A and J and their respective numerical values.Make sure that the second character entered is by the user occurs later in the alphabet than the first character.If it does not,write a loop that repeatedly asks the user for a valid second character until one is entered.
This is what i done so far.But i not work.


#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
int i, j, starting, ending;
char a='a';

cout << "Enter the starting character: ";
cin >> starting;
cout << "CHAR DECIMAL OCTAL HEXADECIMAL\n";
cout << "---- ------- ----- ------------\n";

for (i = 1; i <= starting; i++)
{
cout << "Enter the ending character: " << i << endl;
for (j=1; j<=ending; j++)
{
cout << "\t " << int (a) << " " << endl;
cout << "\t " << oct << int (a) << " " << endl;
cout << "\t " << hex << int (a) << " " << endl;
}



}
system ("PAUSE");
return 0;
}
First problem. You never actually get the user's input for the ending character.

Second problem. Why would you ask for the user's ending character inside the for loop?

Third problem. The hex and oct manipulators are sticky, meaning that the second time through
your inner for loop, your first cout will be in hex since that was the last one you used in the
previous iteration.

Topic archived. No new replies allowed.