answer.
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
gtnhenbr
2 months 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:
Rzqust [1K]2 months ago
5 0

Response:

C++

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

#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
What feature would be used to collect how many times users downloaded a product catalog?
ivann1987 [1066]
Event Tracking is an important capability within Google Analytics used to capture user interactions with various website elements.
8 0
2 months ago
In the Advent of computer technologies and it's applications, to what extent these technologies have influenced the world.
amid [951]
One significant aspect explored by numerous researchers regarding the progression of ICT is its effect on social interactions. In his 1995 article "Bowling Alone," Robert Putnam suggested that as ICT usage increases, people's social capital decreases.
8 0
1 month ago
Define a function UpdateTimeWindow() with parameters timeStart, timeEnd, and offsetAmount. Each parameter is of type int. The fu
oksian1 [950]
The UpdateTimeWindow() function takes timeStart, timeEnd, and offsetAmount as parameters. Both timeEnd and timeStart are pointers. Within this function, the syntax to modify these parameters is as follows: *timeStart += offsetAmount, incrementing the start time by offsetAmount, and similarly, *timeEnd += offsetAmount increments the end time by the same amount.
8 0
1 month ago
A company operates on two types of servers: 2 large servers (L) and 4 smaller servers (S), with a combined total of 64GB RAM. Th
oksian1 [950]

Reasoning:

Let's denote the size of a large server as L and the size of a smaller server as S.

According to the data provided, we have two equations:

2L + 4S = 64.............(1)

and

L + 3S = 40...............(2)

To solve the equations, we proceed as follows:

2(2)-(1)

2L - 2L + 6S - 4S = 2*40 - 64

2S = 16

thus, S = 8..................(3), which indicates the size of the small server

Using (3) in (2) yields

L + 3(8) = 40

L = 40 - 24 = 16..............indicating the size of the large server

8 0
1 month ago
Other questions:
  •  How does critically analyzing technology add value to interactions with people in personal and professional contexts?
    9·2 answers
  • Assume that getPlayer2Move works as specified, regardless of what you wrote in part (a) . You must use getPlayer1Move and getPla
    14·1 answer
  • Which of the following is true? a. Pseudocode is used to describe an algorithm. b. Pseudocode is not an actual computer programm
    11·1 answer
  • A developer writes a trigger on the Account object on the before update event that increments a count field. A workflow rule als
    12·1 answer
  • One form of Intrusion Detection System (IDS) starts operation by generating an alert for every action. Over time, the administra
    5·1 answer
  • Write a class for a Cat that is a subclass of Pet. In addition to a name and owner, a cat will have a breed and will say "meow"
    9·1 answer
  • The function below takes two numeric parameters. The first parameter specifies the number of hours a person worked and the secon
    13·1 answer
  • A bicycle sharing company is developing a multi-tier architecture to track the location of its bicycles during peak operating ho
    11·1 answer
  • Given x and y, each associated with an int, write a fragment of code that associates the larger of these with another variable n
    5·1 answer
  • The maximum number of times the decrease key operation performed in Dijkstra's algorithm will be equal to ___________
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!