adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C and C++ to print each digit of number in word

Program in C and C++ to print each digit of number in word 



C
CPP
#include<stdio.h>
  int main()
    {
        long int i,n,rev=0;
     char num[][12]={"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"};
     printf("Enter a number:-");
     scanf("%d",&n);
     while(n!=0)
       {
        rev=n%10+10*rev;
        n/=10;
    }
      while(rev!=0)
       {
        i=rev%10;
        printf("%s ",num[i]);
        rev/=10;
    }
   return 0;
 }
#include<iostream>
 using namespace std;
  int main()
    {
        long int i,n,rev;
     char num[][12]={"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"};
     cout<<"Enter a number:-";
     cin>>n;
     while(n!=0)
       {
        rev=n%10+10*rev;
        n/=10;
    }
      while(rev!=0)
       {
        i=rev%10;
        cout<<" "<<num[i];
        rev/=10;
    }
   return 0;
 }
Output:-









Post a Comment

0 Comments