Answer to Question #290040 in C for Squishy

Question #290040

Create a program that will take in an input integer number from the user. And will display each digit in word form. However, three digits will instead be shown as an enlarged font. 


1
Expert's answer
2022-01-23T09:41:05-0500
#include <iostream>
#include <vector>
 

int main()
{
    int n, r;
    std::cout<<"Enter digit: ";
    std::cin>>n;
    std::vector<int> digits;
    while(n!=0)
    {
        r =n % 10;
        n =n / 10;
        digits.push_back(r);
    }
    for(auto i = digits.rbegin(); i != digits.rend();++i)
    {
        switch(*i)
        {
            case 0:
                std::cout<<"zero ";
                break;
            case 1:
                std::cout<<"one ";
                break;
            case 2:
                std::cout<<"two ";
                break;
            case 3:
                std::cout<<"three ";
                break;
            case 4:
                std::cout<<"four ";
                break;
            case 5:
                std::cout<<"five ";
                break;
            case 6:
                std::cout<<"six ";
                break;
            case 7:
                std::cout<<"seven ";
                break;
            case 8:
                std::cout<<"eight ";
                break;;
            case 9:
                std::cout<<"nine ";
                break;
        }
    }
}

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
APPROVED BY CLIENTS