Question
Simple Conditionals and Loops Write a program that repetitively requests signed integer numbers between -100 and +100 from the user though the keyboard (using printf()
Simple Conditionals and Loops
Write a program that repetitively requests signed integer numbers between -100 and +100 from the user though the keyboard (using printf() and scanf()) until the user enters 0 when she/he wants to quit. Test each entry for whether the number entered is positive or negative. Create two variables that accumulate the values of the numbers entered - one for the positive numbers and one for the negative numbers. The program shall also ask the name of the user and save it to a string variable. Upon completion of the data entry process (when the user enters 0), the program prints out the name of the user, the number and the total of the positive numbers entered, and the number and the total of the negative numbers entered. Then, it should also print out the algebraic total of the sum total of the positive entries minus the sum total of the negative entries.
Furthermore, the users entry must be checked to ensure that it is within the range specified. If it is out of range, then it should print out Entry out of range. Please try again. It should furthermore give the user two more chances to enter a correct value. After two more chances, it should exit without providing an answer, and print out OK, were done here. Bye.
There is no need to save any of the individual values during the program execution - only their cumulative totals and the number of positive and negative numbers (separately!) entered. The output should be as follows:
You entered
You entered
The algebraic sum of the total positive and negative entries is:
Where the labels between <> represent the values of the variables that will be printed in its place.
Program Specifications: (musts)
There are several requirements (musts) in this assignment:
1. Your program must make use of at least one conditional structure (doesnt matter which one).
2. Your program must make use of at least one loop structure (doesnt matter which one).
3. Your program must use scanf() to obtain the users entries.
4. Your program must use printf() to print out the results to the screen.
5. Lastly (and obviously!), your program must be written in C and must compile and execute correctly on Code::Blocks using the GCC compiler.
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