Answer to Question #128907 in C++ for tryks

Question #128907
Write a program that takes a digit as input and returns its string representation (1 - one, 2 - two, etc.).
1
Expert's answer
2020-08-11T10:45:53-0400
#include <iostream>

using namespace std;

int main() {
    cout << "Input number: ";
    int number = -1;
    cin >> number;
    switch (number) {
        case 1:
            cout << "1 - one";
            break;
        case 2:
            cout << "2 - two";
            break;
        case 3:
            cout << "3 - three";
            break;
        case 4:
            cout << "4 - four";
            break;
        case 5:
            cout << "5 - five";
            break;
        case 6:
            cout << "6 - six";
            break;
        case 7:
            cout << "7 - seven";
            break;
        case 8:
            cout << "8 - eight";
            break;
        case 9:
            cout << "9 - nine";
            break;
        default:
            cout << "Unexpected symbol";
    }
    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
APPROVED BY CLIENTS