adsense

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

Write a program in C to convert given number into word.(1 to 100)

Write a program in C to convert given number into word.



#include<stdio.h>
#include<conio.h>
 int main()
  {
   int n;
   char num[21][12]={" ","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven"
 ,"Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
     printf("Enter a any one  number between 1 to 100:-");
     scanf("%d",&n);
     if(n>=1&&n<20)
       printf("%s",num[n]);
      else
        {
         switch(n/10)
          {
             case 2:n=n%10;
                    printf("Twenty %s",num[n]);
                    break;
             case 3:n=n%10;
                    printf("Thirty %s",num[n]);
                    break;
             case 4:n=n%10;
                    printf("Forty %s",num[n]);
                    break;
             case 5:n=n%10;
                    printf("Fifty %s",num[n]);
                    break;
             case 6:n=n%10;
                    printf("Sixty %s",num[n]);
                    break;
             case 7:n=n%10;
                    printf("Seventy %s",num[n]);
                    break;
             case 8:n=n%10;
                    printf("Eighty %s",num[n]);
                    break;
             case 9:n=n%10;
                    printf("Ninety %s",num[n]);
                    break;
             case 10:printf("One Hundred");
                     break;
            }
         }
   getch();
  }
Output:-











Post a Comment

0 Comments