Please explain how variables of type bool in C ++ work using cycles and conditions.
|
1 answer
It's hard to come up with a good example that explains everything. Such an example
bool var = true; int count; while (var) { count = count + 1; if (count > 100) var = false; }
The loop is executed while var true. The counter grows each time, and once the if will work (count> 100) and set var to false and then the loop will stop running.
|