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
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"); }
Comments
Leave a comment