76 289
Assignments Done
Successfully Done
In May 2019

Answer to Question #13779 in C++ for shalennee

Question #13779
write a program that reads an unspecified number of integers,determines how many positive and negative values have been read, and computes the total and average of the input values(not counting zeros). your program ends with the input 0. Display the average as floating-point number.
Expert's answer
#include <iostream>

using namespace std;

int main()
int number=0,positive=0,negative=0,sum=0;
cout<<"Start entering numbers: ";
while (true)
& cin>>number;
& if (number==0)
& {
& }
& if (number>0)
& {
& }
& else
& {
& }
& sum+=number;
cout<<positive<<" positive numbers"<<endl;
cout<<negative<<" negative numbers"<<endl;
cout<<"total: "<<sum<<endl;
cout<<"average: "<<((float)sum)/(positive + negative)<<endl;
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


Assignment Expert
26.06.14, 17:51

Dear customer,
Unfortunately, your question requires a lot of work and cannot be done for free. 
Please submit it with all requirements as an assignment to our control panel and 
we'll assist you. 

10.05.14, 16:10

i need some one who can try to give me some explanation about this codes
because i want to understand the logic of those codes

Leave a comment

Ask Your question

Privacy policy Terms and Conditions