Write a program that asks the user for anumber, then prints the English word for
ID: 3619023 • Letter: W
Question
Write a program that asks the user for anumber, then prints the English word for the number. In thisprogram, we will only consider numbers which are positive and whichare 6 digits or less. If the number is negative, or if it has morethan 6 digits, then the program should print “Please enterpositive numbers which are no more than 6 digits in length.”to the screen and exit the program. Without using strings Write a program that asks the user for anumber, then prints the English word for the number. In thisprogram, we will only consider numbers which are positive and whichare 6 digits or less. If the number is negative, or if it has morethan 6 digits, then the program should print “Please enterpositive numbers which are no more than 6 digits in length.”to the screen and exit the program. Without using stringsExplanation / Answer
please rate - thanks #include #include void print(int); void printword(char[]); int main() {int n; printf("enter a number: "); scanf("%d",&n); if(n999999) {printf("Please enter positive numbers which are nomore than 6 digits in length "); printf("Program aborting "); } else print(n); getch(); return 0; } void printword(char w[]) {int i; for(i=0;w[i]!='';i++) printf("%c",w[i]); printf(" "); } 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) {printword(upto20[n]); printf("hundred "); } num%=100000; n=num/10000; if(n>0) printword(tens[n]); num%=10000; n=num/1000; if(n>0) {printword(upto20[n]); printf("thousand "); } num%=1000; n=num/100; if(n>0) {printword(upto20[n]); printf("hundred "); } num%=100; if(num>=20) {n=num/10; if(n>0) printword(tens[n]); } else if(num>=10) { printword(upto20[num]); return; } num%=10; if(num>=0) printword(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.