decimal,octal and hexadecimal

closed account (1RLTURfi)
I am a new beginner in c++.i want to 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 characters 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.

i totally no idea how to do this.anyone help.
With C++ streams use manipulators instead of printf: http://www.cplusplus.com/reference/iostream/manipulators/
closed account (1RLTURfi)
thank you for all of you.it helps me a lot.i appreciate it!but i done this so far,and not success,i believe there something missing.can someone help me.

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

int main()
{
int start , end , n ;
char key;





char a = 'a';
cout << 'a' << endl;
cout << "dec" << 'a' << endl;
cout << "oct" << 'a' << endl;
cout << "hex" << 'a' << endl;
cout << 'a' << endl;
cout << int (a) << endl;
cout << "oct" << int (a) <<endl;
cout << "hex" << int (a) << endl;

char j = 'j';
cout << 'j' << endl;
cout << "dec" << 'j' << endl;
cout << "oct" << 'j' << endl;
cout << "hex" << 'j' << endl;
cout << 'j' << endl;
cout << int (j) << endl;
cout << "oct" << int (j) <<endl;
cout << "hex" << int (j) << endl;





cout << "Enter the starting character: ";
cin >> start;
cout << "Enter the ending character: ";
cin >> end;



cout << "\nCHAR DECIMAL OCTAL HEXADECIMAL\n";
cout << "------ --------- ------- -------------\n";


for (n = 1; n <= end; n++)
n=97;


cout << setw(10) << "dec (base 10)" << showbase << dec << n << endl;
cout << setw(10) << "oct (base 8)" << showbase << oct << n << endl;
cout << setw(10) << "hex (base 16)" << showbase << hex << n << endl;



system ("pause");


return 0;
}
Topic archived. No new replies allowed.