Write a program to convert number into word. e.g. If input is 953 then output will be Nine Five Three

#include<stdio.h>

#include<math.h>

 

int main()

  {

      Int  a, n, r, k, temp;

      printf( "Enter an integer number: " );

      scanf( "%d" ,&n);

      temp=n;

      r=0;

      while(n>0)

          {

             r=r*10 + n%10;

             n=n/10;

           }

 

      while(temp>0)

           {

              a=r%10;

              r=r/10;

             temp=temp/10;

              switch (a)

                {

                    case 1:

                          printf( "One " );

                          break;

                    case 2:

                           printf( "Tow " );

                           break;

                    case 3:

                          printf( "Three " );

                          break;

                    case 4:

                           printf( "Four " );

                           break;

                    case 5:

                          printf( "Five " );

                          break;

                    case 6:

                           printf( "Six " );

                           break;

                    case 7:

                          printf( "Seven " );

                          break;

                    case 8:

                           printf( "Eight " );

                           break;

                    case 9:

                          printf( "Nine " );

                          break;

                    default :

                          printf( "Zero " );

                  }

           }

      return 0;

  }

No comments:

Post a Comment