Question
THE FOLLOWING IS A C PROGRAM Design first and _then_ write a program that will read numbers (numeric digits) from an input file. The program
THE FOLLOWING IS A C PROGRAM
Design first and _then_ write a program that will read numbers (numeric digits) from an input file. The program will print the numbers onto the screen in their expanded word form. Your program will be organized into a series of functions. Main() will primarily contain function calls, some variables, and very few, if any, statements.
Your program should handle numbers up to (but not including) 10,000,000. You can choose whether to recognize numbers with commas in them or simply handle only numbers without commas.
Example:
5 - five
123 - one hundred twenty three
1212121 - one million, two hundred twelve thousand one hundred twenty one
(I will provide a .c file with main() and some other useful code in the next couple of days. In the meantime, work on how you will design the functions and algorithms. )
Your main() should look similar to this:
int main(void) {
// variable declarations
int i;
long number;
FILE *input = 0;
char fileName[255];
char numWord[255];
// program intro
printTitle();
// establish input file
while (!input) {
getFileName(fileName); // ask user for file name, store to fileName
input = getFileHandle(fileName); // try to open the file
} // loops until file is opened successfully
// Look through the file; convert digital numbers to words
i = 0;
while (number = getNextNumber(input)) { // loop until number is false (zero)
wordNum = expandToWords(number);
displayNum(number, wordNum);
i++;
}
printf("End of input file ");
printf("%d numbers found ", i);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started