Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Plz help me write this in C language. Operation The program first prints a blank line. It prompts the user Enter either 191 or 919,
Plz help me write this in C language.
Operation
- The program first prints a blank line.
- It prompts the user "Enter either 191 or 919, anything else will quit: ".
- It reads the input value from the same line of the above message.
- It prints a blank line after reading the input.
- Depending on the input value, the program displays one of the three outputs as shown in the above screenshot.
- If the input is neither 191 nor 919, or a value not beginning with 191 or 919, the program quits after a final message "Good bye!". Otherwise, it repeats step 1 to 5. That is, the program keeps running for an input of 191 or 919. It stops only if the input is neither 191 nor 919, or a value not beginning with 191 or 919.
Specifications
- As described in step 5 of operation, the program execution quits immediately if an input is not 191 or 919 or a value beginning with 191 or 919. For instance, when prompted, an input of 22 or -4.67 or abc or $191, +919, etc. will cause the program execution to print "Good bye!" and stop, while 191 or 919 or 191&919 or 191.3 or 91955 or 191 =8, etc. will result one of the two output prints (as shown in the screenshot) and execution continues. Hint: while loop, check returned value of scanf().
- If a message prompt is followed by no input but an Enter or Return key pressed, the program does nothing and keeps waiting for an input. *This is not shown in the above console screenshot but you may test it using the given .exe file.
- Program output format must match exactly what is shown in the above screenshot. Hint: nesting for loops, i.e., for loops within for loop.
- proj1.c doesn't allow to use arrays or any special data structure.
- proj1.c doesn't allow to include any hard coded string literals such as "11", "333333", "666666 666666", etc.
- In addition to the main() function, proj1.c implements two more functions: do_191() and do_919().
- The main() calls do_191() if an input is 191 or a value beginning with 191. It calls do_919() for an input of 919 or a value beginning with 919.
- Both of the above two functions have no input parameters and do not return a value. You may use prime.c (p.190, Chapter 9) as a reference for coding functions. Otherwise, it is very similar to how you do and call methods in Java.
- proj1.c must be coded with good coding style. You may use prime.c (p.190, Chapter 9) or any book program examples as a reference of good coding style.
- proj1.c must compile directly with gcc in command line. Using any IDE is not required.
C:\3515\Proji >proji Enter either 191 or 919, anything else will quit: 191 11 2222 333333 44444444 5555555555 666666666666 77777777777777 8888888888888888 999999999999999999 8888888888888888 77777777777777 666666666666 5555555555 44444444 333333 2222 11 919 Enter either 191 or 919, anything else will quit: 999999999999999999 8888888888888888 7777777 7777777 666666 666666 55555 55555 4444 4444 333 333 22 22 22 333 333 4444 4444 55555 55555 666666 666666 77777777777777 88888888 88888888 999999999999999999 Enter either 191 or 919, anything else will quit: Good bye! C:\3515\Proj). fh6278
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