Write a program in C++ which will take exactly 5-digit number as input and outputs the same number but in words:
Example 1:
Number = 65143
Six Five One Four Three
Answers
Answer:
#include <iostream>
using namespace std;
int main() {
string finalstring="";
int x; string number="";;
cout << "Type a number: "; // Type a number and press enter
cin >> x;
number=NumberToString(x);
for(int i=0;i<=number.length();i++){
switch(expression) {
case 0:
finalstring+=" zero";
break;
case 1:
finalstring+=" one";
break;
case 2:
finalstring+=" two";
break;
case 3:
finalstring+=" three";
break;
case 4:
finalstring+=" four";
break;
case 5:
finalstring+=" five";
break;
case 6:
finalstring+=" six";
break;
case 7:
finalstring+=" seven";
break;
case 8:
finalstring+=" eight";
break;
case 9:
finalstring+=" nine";
break;
default:
return finalstring;
}
}
cout << "Your number in string is: " << finalstring;
return 0;
}
Explanation: