We’re about to learn how to use the bool (true or false) data type to check conditions – in other words, to run code only if some value evaluates to true.
The “if” Block
The “if”
block is a means of evaluating a condition and, if that condition is true, running the code inside the “if” block. The code is somewhat self-explanatory: we type the keyword “if,” then a set of parentheses () in which we type the condition to test, and then a code block {} to run if the condition is true:
if (/* Conditions go here */)
{
//This code only runs if the condition is true.
}
A condition is simply some ...