+ 2

Where can we use Boolean variables?

In which context , we use bool . For what purpose it is used.what's it's functionality

23rd Apr 2017, 5:40 PM
Sri
Sri - avatar
3 Respostas
+ 12
I use them to return certain function calls to see if there was any error in the process....it returns true if everything went fine and false otherwise.
23rd Apr 2017, 5:46 PM
Karl T.
Karl T. - avatar
+ 9
You may use it when you need to switch the truth/falsity of a conditional statement, e.g. bool isFound = false; while (!isFound) { if (//search for something == your key) { isFound = true; } } if (isFound) { cout << "Has been found!"; } else { cout << "Error!"; }
23rd Apr 2017, 5:45 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
while loops are one example.. a boolean variable reading True will run the while loop continuously.. to escape the while loop, change the value of the boolean to false. they are basically ON/OFF switches
23rd Apr 2017, 5:45 PM
LordHill
LordHill - avatar