Create a C++ program that reads N integers and prints their average. Your program should ask first for a value N. Using a while loop, get the N integers and compute their average. At the end, print the average. Your program should print an appropriate message if the user enters 0 as the value for N.
1
Expert's answer
2013-02-20T11:46:54-0500
#include <iostream> using namespace std; int main(){ cout<<"Enter N\n"; int N; cin>>N; if (N==0) cout<<"You entered the wrong number N=0\n"; else { double av = 0; int NN = N; while (NN >0) { NN--; double temp; cin>>temp; av+=temp; } cout<< "Average: "<<av/N<<endl;
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