Giving the user control over the number of times a calculation
is performed.
EXAMPLE:
/* Calculate the length of a line segment, for as many
pairs of coordinates as the user wants to enter */
float x1, y1, x2, y2;
float length;
char response;
response = 'Y'; /* priming the loop */
while (response == 'Y')
{
cout << "Enter first pair of coordinates: ";
cin >> x1 >> y1;
cout << "Enter second pair of coordinates: ";
cin >> x2 >> y2;
length = sqrt ( (x2-x1) * (x2-x1) + (y2-y1) * (y2-y1));
cout << "Length of segment is " << length << endl;
cout << "Do you want to calculate the length of another segment?";
cout << endl << "(Y or N): ";
cin >> response;
}
cout << "Program over" << endl;