The BOTTOM LINE Quote Of The Day

The BOTTOM LINE Quote Of The Day

Don't Ever Tell GOD How BIG Your Problems are.
Just Tell Your Problems How BIG your GOD is ;)

Tuesday, May 29, 2012

Writing the Given Number in alphabets


#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
  int i,b,tmp,nod=0;
  scanf("%d",&b);
  tmp = b;
  while(tmp)
  {
    nod++;      
    tmp = tmp/10;          
  }
  printf("\n");
  while(nod>0)
  {  
   nod--;  
   tmp = 1;      
   for(i=0;i<nod;i++)
    tmp *= 10;
   switch(b/tmp)
   {
     case 0 : printf("Zero "); break;
     case 1 : printf("One "); break;
     case 2 : printf("Two "); 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: break;              
   }  
   b %= tmp;      
  }
  getch();
  return 0;
}

No comments:

Post a Comment