demo-forloop-mean - for(int i = 1 i<= N i sum the data...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Looping demo program: Computing a mean #include <iostream> // for cin, cout, endl using namespace std; const int N = 10; // how many data points int main() { double cur; // current data point double sum = 0; // sum of all data points entered // (same units as data points) double mean; // sample mean // (same units as data points)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for(int i = 1; i <= N; i++) // sum the data points { cout << "Enter a data point: "; // read next data point cin >> cur; sum = sum + cur; // add input to running sum } mean = sum/N; // divide by number of data points cout << "\nSample mean: " << mean; // display result return 0; }...
View Full Document

This document was uploaded on 02/10/2011.

Ask a homework question - tutors are online