1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MArishka [77]
4 years ago
10

This program is to read in a list of integers until the value of -999 is input. Complete the program so that it prints out the n

umber of values read, the total of these values, and the average of these values. 1. Declare the proper variables for the number of values (count), total, and average 2. In the while loop, update your variables after reading a new value 3. Calculate the average 4. Display average, count, and total. The printf statements are already given in the base code.
The code I need to edit is below in C programming language.

#include

int main (int argc, char** argv)

{

int val;



/* prompt the user for input */

printf ("Enter in a list of numbers followed by the terminal value of -999\n");

/* loop until the user enters -999 */

scanf ("%d", &val);

while (val != -999)

{

scanf("%d", &val);

}

/* calculate the average of the values read in */




/* display the results */

/* use the following printf statements to display the results */

/* remove the comments */

//printf ("For the list of %d numbers with a total of %d\n", count, total);

//printf (" the average is: %15.5f\n", average);

return 0;

}
Computers and Technology
1 answer:
kvv77 [185]4 years ago
7 0

Answer:

#include <stdio.h>

int main()

{

   int val, total = 0, count = 0;

   float average = 0;

   printf ("Enter in a list of numbers followed by the terminal value of -999\n");

   scanf ("%d", &val);

   while (val != -999){

   

       if(val != -999){

           total += val;

           count++;

       }

       

       scanf("%d", &val);

   }

   

   average = (float)total / count;

   

   printf ("For the list of %d numbers with a total of %d\n", count, total);

   

   printf (" the average is: %15.5f\n", average);

   return 0;

}

Explanation:

Declare the total, count and average variables

In the while loop:

Add the entered number to the total and increment the count by 1 unless it is -999

Calculate average, divide total by count (Typecast the total as float to get decimal result)

You might be interested in
In a spreadsheet what does the following symbol mean?<br><br> $
Diano4ka-milaya [45]

Answer:

$ = dollar sign

Explanation:

6 0
3 years ago
Limitations of systems analysis and design​
Sonja [21]

Answer:

<h3 />

Explanation:

<h3>Although System analysis offers an extensive range of benefits it might also have some disadvantages. One of the main disadvantages which is mostly overlooked is the risk of too much analysing which may be costly and time consuming. It is therefore part of the analyst's job to find the right balance.</h3>
6 0
3 years ago
Which of the following is not a recommended method to protect you from identity theft?
yaroslaw [1]

Answer:

post them, but id say anything with personal information

7 0
3 years ago
What is the result of successfully applying a Machine Learning (ML)<br> algorithm to analyze data?
DIA [1.3K]

Answer:

Machine Learning algorithms can predict patterns based on previous experiences. These algorithms find predictable, repeatable patterns that can be applied to eCommerce, Data Management, and new technologies such as driverless cars..

5 0
3 years ago
Which of the following best describes open-source web browsers?
Lostsunrise [7]
<span>Following are some best open source CRM software: Really Simple Systems
</span><span>Bitrix24 Raynet SuiteCRM vTiger 
</span>
is this what you are asking for
4 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following locations would most likely have the most fertile soil?
    8·1 answer
  • What is the main function of the motherboard?
    12·1 answer
  • What list did poe appear on for the search engine lycos?
    11·1 answer
  • What actions are considered positive body language?
    12·1 answer
  • Describe the application of computer system in our daily life​
    13·1 answer
  • David is taking a test. To answer a question, he first covers up the answer choices. Next, he tries to answer the question. Then
    15·2 answers
  • Question 2 (6 points)
    11·1 answer
  • Create a mobile app plan using PowerPoint slides to show mock-ups of screens,
    6·1 answer
  • Sharing private information causing a person to be humiliated is considered to be doxing. T or F
    8·1 answer
  • To read encrypted data, the recipient must decipher it into a readable form. What is the term for this process?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!