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
Leviafan [203]
4 years ago
10

Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a

nd computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. Sample Run 1 Enter an integer, the input ends if it is 0: 1 2 -1 3 0 The number of positives is 3 The number of negatives is 1 The total is 5.0 The average is 1.25 Sample Run 2 Enter an integer, the input ends if it is 0: 0 No numbers are entered except 0 Sample Run 3 Enter an integer, the input ends if it is 0: 2 3 4 5 0 The number of positives is 4 The number of negatives is 0 The total is 14 The average is 3.5 Sample Run 4 Enter an integer, the input ends if it is 0: -4 3 2 -1 0 The number of positives is 2 The number of negatives is 2 The total is 0 The average is 0.0
Computers and Technology
1 answer:
GarryVolchara [31]4 years ago
5 0

Answer:

<em>C++</em>

////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <iostream>

#include <vector>

using namespace std;

int main() {

  vector<int> v;

   int n = 1;

   while (n != 0) {

       cout<<"Enter an integer, the input ends if it is 0: ";

       cin>>n;

       v.push_back(n);

   }

   cout<<endl;

   ///////////////////////////////////////////////////////////

   int sum = 0;

   int num_positives = 0, num_negatives = 0;

   for (int i=0; i<v.size()-1; i++) {

       if (v[i] > 0)

           ++num_positives;

       else

           ++num_negatives;

           

       sum = sum + v[i];

   }

   //////////////////////////////////////////////////////////

   cout<<"The number of positives is "<<num_positives<<endl;

   cout<<"The number of negatives is "<<num_negatives<<endl;

   cout<<"The total is "<<sum<<endl;

   cout<<"The average is "<<(float)sum/(v.size()-1);

   ///////////////////////////////////////////////////////////

   return 0;

}

You might be interested in
Is it possible to increase watch hours for a channel by making a playlist out of your videos for people to watch? Will it boost
Irina18 [472]

Answer:

It depends on the person watching

Explanation:

The video that the person is watching has to watched in order for it to count towards your watched hours if one of the videos in that playlist are watched it will get those hours but on the video that has not been watched it will not count it.

4 0
4 years ago
What is the difference between a 13 column abacus and 5 column abacus?
Pepsi [2]

Answer:  The difference between these two types of abaci are the number the beads.

Explanation:

have a great day or night

4 0
3 years ago
Why is updating your anti-virus a good thing?
vladimir2022 [97]

Answer:

Antivirus vendors play a 'cat and mouse' game with malware creators. As malware is discovered definitions are written to discover the program and other programs written in a similar way. If an existing piece of malware is extensively rewritten or a new piece of malware is created, the existing malware definitions are unlikely to detect the program as malicious. This means that antivirus vendors have to find a 'sample' of the new malware being used and create a new definition for it. When you update your anti-virus these malware definitions are downloaded allowing your antivirus to detect this newer malware and keeps your computer secure from these newer threats.

7 0
3 years ago
Which programming element is used by a game program to track and display score information?
lubasha [3.4K]
I think is Variablesss
7 0
3 years ago
Read 2 more answers
What is a variable in programming?
HACTEHA [7]
A symbol or set of characters in a programming statement whose value can be changed
3 0
3 years ago
Other questions:
  • What is the mass of the light bulb? a. 425.6 g b. 204.6 g c. 240.56 g d. 245.6 g
    6·2 answers
  • In today's computers, the CPU tells _______________ the clock speed it needs, and the clock chip then automatically adjusts for
    6·1 answer
  • . Suppose that name is a variable of type string. Write the input statement to read and store the input Brenda Clinton in name
    5·1 answer
  • Write a short program that uses a for loop to write the numbers 1 through 10 to a file
    11·1 answer
  • Rita wants to know the size of each image in a folder. Which view will help her find this information quickly?
    13·1 answer
  • I need help with getting a profile pic
    5·1 answer
  • Write a function findWithinThreshold that identifies the elements of a given array that are inside a threshold value. Takes the
    13·1 answer
  • Which of the following is NOT an example of one of the six primary ways businesses use the Internet?
    10·2 answers
  • PLEASE HELP ME ASAP ITS IMPORTANT
    8·2 answers
  • Television, the internet, and smartphones are different communication _______blank hsn uses in its imc.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!