this loop will not exit when n is pressed I sure would appreciate a clue as to how to exit a loop. here is the code.

// Ex3_12.cpp
// using a while loop to compute an average
using std::cin;
using std::cout;
using std::endl;
int main( void )
double value = 0.0; // Value entered stored here
double sum = 0.0; // Total of value accumulated here
int i = 0; // Count of number of values
char indicator = 'y'; // Continue or not
while(indicator = 'y') // Loop as long as y is entered
cout << endl
<< "Enter a value: ";
cin >> value; // Read a value
++i; // Increment count
sum += value; // Add current input to total

cout << endl
<< "Do you want to enter another value enter n to end)? ";
cin >> indicator; // Read indicator
cout << endl
<< "The average of the " << i
<<" value you entered is " << sum/i << "."
<< endl;
return 0;

Thanks Dick

11 Years
Discussion Span
Last Post by ~s.o.s~

Plus you need to convert the character to lowercase so as not to force the user to enter 'y' in lower case only. while(tolower(continue) == 'y')

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.