Answer:
#include <bits/stdc++.h>
using namespace std;
string value(int i)//function return the string of the integer..
{
if(i==0)
return "Zero";
if(i==1)
return "One";
if(i==2)
return "Two";
if(i==3)
return "Three";
if(i==4)
return "Four";
if(i==5)
return "Five";
if(i==6)
return "Six";
if(i==7)
return "Seven";
if(i==8)
return "Eight";
if(i==9)
return "Nine";
}
int main() {
int n,a[100],c=0;
cout<<"Enter the integer"<<endl;
cin>>n;//taking input of n..
while(n>0)//storing the integer in the array in reverse order..
{
int digit=n%10;
a[c++]=digit;
n/=10;
}
int s=0,e=c-1;
while(s<=e)//reversing the array.
{
int temp=a[s];
a[s]=a[e];
a[e]=temp;
s++;
e--;
}
for(int i=0;i<c;i++)//printing the string according to the number..
{
cout<<value(a[i])<<" ";
}
cout<<endl;
return 0;
}
Output:-
Enter the integer
230
Two Three Zero
Step-by-step explanation:
I have created a function which returns string according to the integer.So i have taken an array to store the digits of the number and reversing it so the number is stored as it is in the array.Then printing the numbers accordingly.