Question: Could someone with expertise in C programming help me with the following code? It seems simple, and short, but I'm a bit lost on how
Could someone with expertise in C programming help me with the following code? It seems simple, and short, but I'm a bit lost on how to do it. Thank you so much for your help!
Create a program in the C language that does the following:
- Create a loop that loops from 1 to 999, inclusive.
- For each number in the loop, output the equivalent word English
- You will need to separate the number into three digits - the one's, ten's, and hundred's digit.
- To do this, divide by 1, 10, or 100, and take modulo 10 - this will give you a single digit.
- For example, this variable will store the hundred's digit: int hundreds = (number / 100) % 10;
- And then, use variable "hundreds" in a switch-case to output the word(s) for one hundred, two hundred, etc.
- Then, find the ten's digit, then the one's digit.
- Output the number, an equals sign, and then the number in your chosen language.
- Put a space between the words for hundred's, ten's, and one's place.
- When displaying on the commandline, the numbers 1 to 999 will quickly scroll by too fast and too much to check your output.
- To verify your output, use redirection to store the output into a text file named output.txt.
- For example, to redirect output to a file: ./program > output.txt
- This will generate a .txt file containing the print
- Other tips
- Only 1 loop is needed, that is the loop that counts from 1 to 999.
- Only 4 variables were needed, all of them integer variables.
- Whether you are using if-statements or switch-cases, you will have 3 consecutive groups (PLEASE USE SWITCH CASES)
- Each for the one's, ten's, and hundred's.
- Order MATTERS! Check the hundreds first, then the tens, then the ones.
- There is no user input in this program.
Output should look like this: This program counts in English from1 to 999. 1 = one 2 = two 3 = three 999 = nine-hundred ninety nine
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
