Answer to Question #319670 in C++ for warras

Question #319670

Exercise 1.1 : Base and ASCII representation of character representation Print the decimal, octal and hexadecimal value of all characters between the start ad stop characters entered by a user. for example, if the user enters an ’A’ and ’H’, the program should print all the characters between ’A’ and ’H’ and their respective values in the different bases (decimal, octal, and hexadecimal) as follows ASCII Representation of D is 68 in Decimal 104 in Octal and 44 in Hexadecimal ASCII Representation of E is 69 in Decimal 105 in Octal and 45 in Hexadecimal ASCII Representation of F is 70 in Decimal 106 in Octal and 46 in Hexadecimal ASCII Representation of G is 71 in Decimal 107 in Octal and 47 in Hexadecimal ASCII Representation of H is 72 in Decimal 110 in Octal and 48 in Hexadecimal ASCII Representation of I is 73 in Decimal 111 in Octal and 49 in Hexadecimal ASCII Representation of J is 74 in Decimal 112 in Octal and 4A in Hex


1
Expert's answer
2022-03-28T13:52:31-0400
#include <iostream>
using namespace std;


int main() {
    char start, end;


    cout << "Enter first character: ";
    cin >> start;
    cout << "Enter last character: ";
    cin >> end;


    for (char ch=start; ch<=end; ch++) {
        int n = ch;
        cout << "ASCII Representation of " << ch 
             << " is " << dec << n << " in Decimal "
             << oct << n << " in Octal and " 
             << hex << n << " in Hexadecimal" << endl;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog