+ 2
Where can we use Boolean variables?
In which context , we use bool . For what purpose it is used.what's it's functionality
3 Respuestas
+ 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.
+ 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!";
}
+ 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