I would like to test a condition (using "if") on each recurrence of a while loop, but once the condition has been fulfilled the first time, it is bypassed for the rest of the while loop.
eg.
x = 0.1;
while (x < 1.3) {
if (x == 0.9 || x == 0.5) {
cout << "Helloooooo !!!" << endl;
}
x = x + 0.1;
}
It prints "Helloooooo !!!" once only, at x = 0.5, not again at x = 0.9.
Is there a way to get it to evaluate the condition every time?
eg.
x = 0.1;
while (x < 1.3) {
if (x == 0.9 || x == 0.5) {
cout << "Helloooooo !!!" << endl;
}
x = x + 0.1;
}
It prints "Helloooooo !!!" once only, at x = 0.5, not again at x = 0.9.
Is there a way to get it to evaluate the condition every time?
Comment