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]
3 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]3 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
There are no breakpoints in the "Access Customer Account" subpage however there is an error. What will happen if you choose to s
blsea [12.9K]

Answer:

Move to the breakpoint at "Get Customer Details" stage.

Explanation:

This question is incomplete, we need a diagram and four options to resolve this questions, I attached the diagram and the options.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the breakpoint at "Get Customer Details" stage.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the "Recover1" stage.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the stage containing the error on the "Access Customer Account" page.

- The process will work all stages in the "Access Customer Account" page until the error is thrown and then focus would move to the "Exception1" stage.

In this case, we are going to run an extra from subpage testing in <u>Process studio</u>. Process studio is a tool where we can test these processes.

The process always it's going to work all stages in the "Access Customer Account" we're going to receive an interruption when the error is activated, moving the focus to the Get Customer Details stage.

There is an error in the stage Access Customer Account, if we run the processes with the Go button, the focus should move into the Recover1 stage, and should show the error.

But in this particular example, we must use the STEP OUT BUTTON, What means this?

The process it's going be executed, but won't show any error or message, because we have used the STEP OUT BUTTON.

If we use the STEP OUT BUTTON, the process should end but in this case, we have a breakpoint in Get Customer Details stage, for that the focus and the process will end in Get Customer Details stage and not at the end or at the Recover1 stage.

8 0
2 years ago
How many responses does a computer expect to receive when it broadcasts an ARP request?why?
Alla [95]

Answer: The response that is expected when it broadcast an ARP request is one or zero.

Explanation: ARP request means Address Resolution Protocol which is a protocol responsible for the mapping of the IP(Internet protocol)address of a system to the MAC(Media Access Control) layer. Only one response is received only if the IP address is present in the ARP otherwise if the IP address does not matches then no response is returned.Thus only one or zero response can be received when a ARP request is process.

5 0
2 years ago
In mathematics, "quadrant I" of the cartesian plane is the part of the plane where x and y are both positive. Given a variable,
lbvjy [14]

Answer:

#include <iostream>

using namespace std;

struct Cartesian {

double x;

double y;

};

int main() {

// creating a pointer p of type struct Cartesian

struct Cartesian *p = new Cartesian ;

cout << " Enter x: ";

// accessing the structure variable x by arrow "->"

cin >> p->x;

cout << "Enter y: ";

// accessing the structure variable y by arrow "->"

cin >> p->y;

// expression to check whether x and y lie in Quadrant 1

if (p->x > 0 && p->y > 0) {

 cout << "X and Y are in Quadrant 1 ";

}

else

{

 cout << "x And y are not in Quadrant 1";

}

// deleting the struct pointer p

delete p;

return 0;

}

Explanation:

in order to locate memory in heap, keyword "new" is used in C++ so,

struct Cartesian *p = new Cartesian ;

in order to access data members of the structure using pointer we always use an arrow "->". otherwise a dot oprerator is used to access data members.

in order to check whether x and y lie in 1st quadrent, we must use && operator in our if condition. so

if (p->x > 0 && p->y > 0)

&& will return true iff x and y both are +ve.

deleting the struct pointer p is important beacuse we are allocating memory in heap so heap memory should be used a resource and must be release when not needed otherwise it can cause memory leakage problems. so  

delete p;

5 0
3 years ago
The procurement department of an organization helps to program software. <br> A)True<br> B)False
valina [46]
I think it is true absolutely
8 0
2 years ago
Read 2 more answers
15. Feelings (maps, coins, clues, etc.) and the invisClue books were some innovative ways used to keep __________ players engage
Anit [1.1K]

Answer:

pong i could be wrong i think its right tho

Explanation:

5 0
2 years ago
Read 2 more answers
Other questions:
  • Which statement describes the word "iterative"?
    7·2 answers
  • What is the type of account and normal balance of allowance for uncollectible accounts?
    13·2 answers
  • Why is it important to evaluate the website on which you plan to shop?
    11·2 answers
  • IT investments can lead to developing IT capabilities and dynamic IT competencies, which can lead to achieving the following six
    5·1 answer
  • There is usually a positive side and a negative side to each technology improvement. Select a technology you use every day and c
    5·1 answer
  • Which is a false statement considering copyright law?
    13·2 answers
  • Which of the following comments are correct? Select all that apply.
    14·1 answer
  • Priortization is an example of a skill that helps you reach long term goals because
    14·1 answer
  • If I bought mine craft p.e. for 7.99 and hook my Micro soft account up, will i get java edition
    11·1 answer
  • The ________ function will change a character argument from lowercase to uppercase. isupper toupper tolarge fromlower none of th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!