# How to convert the number into Characters in a sentence using C++

[793 views]

In this tutorial we will learn how can we convert numbers in characters using C++ program. The main motive of this program is when a user give an integer input this program will convert all the numbers into characters individually. The best part of this program is you will learn about while loop and switch statement of C++ program. First we take an user input which will be integer data type and then the while loop will run twice to get every number of the input individually. Then the switch statement will execute and we need to define the numbers from 0-9 with the character. Thus the program can able to convert the number in character.

## C++ Program For Converting Number in Characters

#include <iostream> using namespace std; int main() { long int n,sum=0,r; cout<<"Enter the Number= "; cin>>n; while(n>0) { r=n%10; sum=sum*10+r; n=n/10; } n=sum; while(n>0) { r=n%10; switch(r) { case 1: cout<<"one "; break; case 2: cout<<"two "; break; case 3: cout<<"three "; break; case 4: cout<<"four "; break; case 5: cout<<"five "; break; case 6: cout<<"six "; break; case 7: cout<<"seven "; break; case 8: cout<<"eight "; break; case 9: cout<<"nine "; break; case 0: cout<<"zero "; break; default: cout<<"Please Enter Valid Number "; break; } n=n/10; } }

## Output

Enter the Number= 742 seven four two

## Struggling to Understand Algorithm and Flowchart? Try our Notes

#### Want to Test Your Knowledge on Algorithm and Flowchart?

##### Play 2048 Game Online and Relax. 