76 836
Assignments Done
Successfully Done
In June 2019

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

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