Convert digits into words

#include<stdio.h>

int main()
{

    int number,i=0,j,digit;
    char* word[1000];

    printf("Enter any integer: ");
    scanf("%d",&number);

    while(number){

    digit = number %10;
    number = number /10;

         switch(digit){
             case0: word[i++] = "zero"; break;
             case1: word[i++] = "one"; break;
             case2: word[i++] = "two"; break;
             case3: word[i++] = "three"; break;
             case4: word[i++] = "four"; break;
             case5: word[i++] = "five"; break;
             case6: word[i++] = "six"; break;
             case7: word[i++] = "seven"; break;
             case8: word[i++] = "eight"; break;
             case9: word[i++] = "nine"; break;

         }
    }
  
    for(j=i-1;j>=0;j--){
         printf("%s ",word[j]);
    }

    return 0;

}

Share this

Related Posts

Dear User,

Thank you for your comment. Hope you like this blog. Kindly share us on Social Media so others can be updated.

-Chief Administrative Officer.