# 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

#include<iostream>

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: ";

cin>>N;

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";

system("pause");

}

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: ";

cin>>N;

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";

system("pause");

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment