Answered step by step
Verified Expert Solution
Question
1 Approved Answer
WRITE CODE IN C. Only use switch operators and don't hardcode each number. Print numbers 1-99 (one, two, three, four, five, six, seven, eight, nine,
WRITE CODE IN C. Only use switch operators and don't hardcode each number. Print numbers 1-99 (one, two, three, four, five, six, seven, eight, nine, ten, eleven...)
Concepts to Practice - For loops and/or do/while loops - The conditional (ternary) operator and/or the switch statement - Extend Prelab 4 Submission Information Submit this assignment by following the instructions given by your TA. SUBMIT ONLY the .c file (no a.out or executable file is required). All of the lab assignments must be submitted before the end of the lab using the lab code given by the TA. Use the following submit command: mucs submit For example: mucs submit 1050 lab4 lab4.c Description For the lab assignment, you may use any C statements you wish. However, you will get bonus points if you correctly solve the problem without using the if statement, the if/else statement, nor the while statement. Similar to the prelab, you are to convert integers to words. For example, if the integer is 1 , you should print "one". If the integer is 2, you should print "two". Do not "hard code" things (i.e., don't just print "one two three four five six seven eight nine ten" but instead loop through all the integers). You may use a for loop or a do/while loop to accomplish this. Inside your loop, you will need some way to decide what to print based on the value of the current integer. To accomplish this part, consider using a switch or the ternary operator. The difference this time is that you need to print all integers from 1 through 99 ! Don't worry about hyphenating and don't worry if there is an extra space or two floating around. Do, however, put a comma between each number (so we can easily tell which is which). If you have an extra comma or two floating around, don't sweat that either. Hints - Structure your code so you print a word that corresponds to each digit. How can you figure out what each digit of an integer is? Well, how about good old integer division? - Don't worry about the "teens" at first. Start with just pretending that ten is "teen", eleven is "teen one", and twelve is "teen two" (if English made any sense, that's what it would be anyway). If you get everything else done, you can always go back and try to deal with the teens
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