Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please give me the code in C Description: This assignment is to write a program to read unknown number of scores (double type) from the
Please give me the code in C
Description: This assignment is to write a program to read unknown number of scores (double type) from the keyboard and calculate the sum and average of the scores. The program will repeatedly read positive scores until it reads a non-positive number, such as 0 or negative values. After reading the non-positive score, the program should output the sum and the average to the screen. Make sure the last input will not be part of the result. For example, if the user enters -12 to quit (as below), then -12 should not be part of the calculation. You don't need to use an array to store all the scores (we haven't learned it so far, but most importantly, it is not necessary!). Use variables to store the sum and number of scores as you read (read the textbook if you don't know how to do it!), and calculate the average after the user enters the non- positive value. Program Output: >run Enter a positive score (0 or negative to quit): 90.1 Enter a positive score (0 or negative to quit) 92 Enter a positive score (0 or negative to quit): 93.5 Enter a positive score (0 or negative to quit) -12 The sum is: 275.60, average is: 91.87 If no one invalid input at all, then output "No sum and average calculated! " with a new line ore quit the program. rur Enter a positive score (0 or negative to quit): -12 No sum and average calculatediStep 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