0 votes
127 views
in C programming by (98.9k points)
edited
C Program to Print Digits of a Number in English Words

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include<stdio.h>
#include<conio.h>  
 
void printDigit(int digit);
int main() {
    int reverse = 0, digit, num, mod;
    printf("Enter a positive Integer\n");
    scanf("%d", &num);
 
    /* reverse the input number */
    while (num > 0) {
        reverse = (reverse * 10) + num % 10;
        num /= 10;
    }
    num = reverse;
 
    while (num > 0) {
        digit = num % 10;
        printDigit(digit);
        num = num / 10;
    }
         
 getch();
    return 0;
}
 
void printDigit(int digit){
 switch (digit) {
        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;
    }
}

 

Related questions

0 votes
1 answer 138 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 172 views
+1 vote
1 answer 200 views
0 votes
1 answer 147 views
asked Aug 21, 2022 in Discuss by codelikepro (3.5k points)
0 votes
1 answer 220 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 129 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...