
Chapter 6: Prelab Assignment
Looping | 133
Name __________________________________________ Date _______________________
Section _________________________________________
Read program Count carefully.
// Program Count prompts for, reads, echo-prints, and sums a
// fixed number of integer values. The sum is printed.
#include <iostream>
using namespace std;
const int LIMIT = 10;
int main ()
{
int counter; // Loop-control variable
int sum; // Summing variable
int dataValue; // Input value
counter = 1;
sum = 0;
// Input and sum integer data values.
while (counter <= LIMIT)
{
cout << "Enter an integer value. Press return."
<< endl;
cin >> dataValue;
sum = sum + dataValue; ...