The question says to write a program asking the user to enter 2 digit number, then prints the English word for it. Suppose you enter \'41\' the printf function prints out \'
#include
int main(void)
{
int num;
printf("Enter a two digit number: ");
scanf("%d",&num);
if(num>10 && num<20){
badnums(num);
}
else{
goodnums(num);
}
return 0;
}
void goodnums(int num){
switch(num % 10) {
case 0: break;
case 1: printf("ten"); break;
case 2: printf("twenty"); break;
case 3: printf("thirty"); break;
case 4: printf("forty"); break;
case 5: printf("fifty"); break;
case 6: printf("sixty"); break;
case 7: printf("seventy"); break;
case 8: printf("eighty"); break;
case 9: printf("ninety"); break;
}
switch(num / 10) {
case 0: 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;
}
}
void badnums(int num){
//handle the numbers here 11-19
}