Can someone please explain me why there are 2 while statements in this code? I understand the second and last while statement, but what is the first 1 doing there en why is it included in the body of the do (while) statement?
#include <iostream>
using namespace std;
int main()
{
char ch;
double cijfer, som =0.0, gemiddelde;
int aantal =0;
do
{ cout << "Voer cijfer in: ";
cin >> cijfer;
cin.get();
if (cijfer <1.0 || cijfer>10.0)
{ cout <<'\a';
cout << "Dit was geen geldig cijfer " << endl;
continue;
}
aantal++;
som += cijfer;
cout << '\a';
cout << "Meer cijfers invoeren? (j of n): ";
cin>> ch;
while(cin.get() != '\n');
cout << endl;
}
while ( ch!= 'n');
I erased the first while statement a few times and the program did not change at all, meaning the first while statement is unnecessary right?
Plz help me out on this one