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.
#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;
}
}
}
Comments
Leave a comment