Conditions
What is a condition?
A condition is a statement that can be evaluated to be true or false. Conditions are used to control the flow of execution of a program.
Syntax
The syntax for a condition is as follows:
if <condition>
{
<statements>
}
else
{
<statements>
}
For example, the following code will print "Correct!" if the value of the variable sum is equal to 5, and "Incorrect!" otherwise:
sum = 4+1
if sum == 5{
"Correct! 4+1 = 5"
}
else
{
"Incorrect!"
}