Skip to main content

34. Number in Characters

 

/* Number in Characters. */


#include <stdio.h>
int main()
{
    int n, r = 0, s;
    printf("Enter a number: ");
    scanf("%d", &n);
    while(n > 0){
        r = r*10 + n%10;
        n = n/10;
    }
    while(r > 0){
        s = r%10;
        switch(s){
            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;
            case 0:
            printf("zero ");
            break;
        }
        r = r/10;
    }
    return 0;
}

Comments