DMCA.com Protection Status
 
Search

Number to Character Conversion in C++

Program to implement Number to Character Conversion in C++

Firstly see what we are going to do ?



Like this

0 - zero

1 – one

2 – two

3 – three

4 – four

5 – five

6 – six

7 – seven

8 – eight

9 – nine

How to do ?

Code

  • #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<<"tttt ";

  • break;

  • }

  • n=n/10;

  • }

  • }




Output –

Enter the Number= 74254

seven four two five four

Why to do ?

Because it is most important program from placement point of view.




For Video Tutorials Subscribe our Youtube Channel

---------------------------------------------------------------------------------------------------------------------------

Previous Page Next Page


Any Doubt ? Feel free to write a comment

Download C++ Projects

Join us on LinkedIn – Great Place of Networking

Follow us on More Together – Facebook for regular updates

Mandatory to join Telegram group for regular job updates

Mandatory to join whatsapp group for regular job updates



Other C++ Programs



For Other Tutorials – Click Here





16 views0 comments

Related Posts

See All

Factorial of a number in C++

In this tutorial we are going to see how to find a factorial of number using C++ program Firstly let’s see a example to understand it better n! = n + (n-1) + (n-2) ! n>=1 3! = 3 *2*1 = 6 Program to fi

Fibonacci Triangle in C++

Program to implement Fibonacci Triangle in C++ #include <iostream> using namespace std; int main() { int a=0,b=1,i,c,n,j; cout<<"Enter the limit: "; cin>>n; for(i=1; i<=n; i++) { a=0; b=1; cout<<b<<"\

Number Triangle in C++

Program to implement Number Triangle in C++ #include <iostream> using namespace std; int main() { int i,j,k,l,n; cout<<"Enter the Range="; cin>>n; for(i=1;i<=n;i++) { for(j=1;j<=n-i;j++) { cout<<" ";

  • Facebook
  • Instagram
  • LinkedIn
  • 1024px-Telegram_logo.svg
  • download
  • YouTube
  • Google Play