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

Question #16295

make a c program to input 20 integers. output the average of all positive odd integers

Expert's answer

#include<iostream>

using namespace std;

int p, N=0;

float s=0;

bool odd(int a){

if (a%2!=0) return true;

& else return false;

}

void main(){

for (int i=0; i<20; i++) {

& cout<<"enter a number: ";

& cin>>p;

& if ((p>=0)&&(odd(p))) { s += p; ++N; }

}

cout<<"The average of all positive odd integers is "<<s/N<<"\n";

system("pause");

}

using namespace std;

int p, N=0;

float s=0;

bool odd(int a){

if (a%2!=0) return true;

& else return false;

}

void main(){

for (int i=0; i<20; i++) {

& cout<<"enter a number: ";

& cin>>p;

& if ((p>=0)&&(odd(p))) { s += p; ++N; }

}

cout<<"The average of all positive odd integers is "<<s/N<<"\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