{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

notes-repetition2-problemsoln - while(count< 20 process...

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

View Full Document Right Arrow Icon
Solution (Revised) double inputData; // holds data point currently being processed double sum; // sum of all data points entered thus far int count; // how many data points we've collected cout << "Enter a number: "; cin >> inputData; sum = inputData; // initialize sum based on first data point count = 1; // start at 1 since a point has already been entered
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: while(count < 20) // process data points { cout << "Enter a number: "; // get more data cin >> inputData; sum = sum + inputData; // add point to running sum count++; // update our count (the update step) } cout << "The sum of the inputs is " << sum << endl; // If we wanted to use count for anything down here, we would need "count--;"...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online