a program that accepts 20 numbers from a user, sieves and pick the even numbers from the 20 numbers and compute the arithmetic mean.displaying all the even numbers collected and the mean using functions.
int m = 0, k = 0, i, arr[20]; void mean(){ for (i=0;i<20;i++){ & if (even(arr[i])){ & m += arr[i]; & k++; & } } }
void main(){ for (i=0;i<20;i++){ & cout<<"enter a number: "; & cin>>arr[i]; } cout<<"\nHere are all entered numbers:\n"; for (i=0;i<20;i++){ & cout<<arr[i]<<" "; } cout<<"\n\nHere are entered even numbers:\n"; for (i=0;i<20;i++){ & if (even(arr[i])) cout<<arr[i]<<" "; }
mean();
if (k!=0){ & m = m/k; & cout<<"\nArithmetic mean of entered even numbers is "<<m; } else cout<<"\nThere are no even numbers."; cout<<"\n\n"; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment