When the if statement is true, the next line will be printed
eg:
1 2 3
if (true)
cout << "The statement is true" << endl;
cout << "This sentence will be displayed even if the statement is false" << endl;
when 2 or more commands need to be executed when an if statement is true, you use the brackets {}
eg:
1 2 3 4 5 6
if (true)
{
cout << "The statement is true" << endl;
cout << "This sentence will only be displayed if the statement is true" << endl;
//other commands that will be executed when the if statement is true
}
if/else can be used as follows:
1 2 3 4 5 6
if (number == 1)
//do this
elseif (number == 2)
//do that
else
//if the number is not 1 nor 2, do this