Write a program that asks the user for anumber, then prints the English word for
ID: 3619022 • Letter: W
Question
Write a program that asks the user for anumber, then prints the English word for thenumber.
Explanation / Answer
please rate - thanks #include #include void print(int); int main() {int n; printf("enter a number(negative to exit): "); scanf("%d",&n); while(n>=0) {print(n); printf("enter a number(negative to exit):"); scanf("%d",&n); } return 0; } void print(int num) {int n; charupto20[20][10]={"zero","one","two","three","four","five","six","seven", "eight","nine","ten","eleven","twelve","thirteen", "fourteen","fifteen","sixteen","seventeen", "eighteen","nineteen"}; chartens[10][10]={"zero","ten","twenty","thirty","forty","fifty","sixty", "seventy", "eighty", "ninety"}; n=num/100000; if(n>0) printf(" %s hundred ",upto20[n]); num%=100000; n=num/10000; if(n>0) printf(" %s ",tens[n]); num%=10000; n=num/1000; if(n>0) printf(" %s thousand",upto20[n]); num%=1000; n=num/100; if(n>0) printf(" %s hundred ",upto20[n]); num%=100; if(num>=20) {n=num/10; if(n>0) printf(" %s ",tens[n]); } else if(num>=10) { printf(" %s ",upto20[num]); return; } num%=10; if(num>0) printf(" %s ",upto20[num]);; printf(" "); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.