60 583
Assignments Done
Successfully Done
In April 2018

Answer to Question #16298 in C++ for paul jimbo uy

Question #16298
input N integers (ask from the user how many numbers he/she wants to input) determine and print the sum of all numbers, the average of all numbers, how many odd numbers were inputted, how many even numbers were entered and how many zeroes inputted
Expert's answer
using namespace std;

int p, N, sum=0, o=0, e=0, z=0;

bool odd(int a){
if (a%2!=0) return true;
& else return false;

void main(){
cout<<"enter the number of integers you want to enter: ";
for (int i=0; i<N; i++) {
& cout<<"enter a number: ";
& cin>>p;
& sum += p;
& if (odd(p)) ++o;
& else ++e;
& if (p==0) ++z;
& p++;
cout<<"The sum is "<<sum<<"\nThe average is "<<sum/N<<"\nThe number of odds: "<<o<<"\nThe number of evens: "<<e<<"\n";

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions