Yes, I copied and pasted this from the C++ lesson.

If statements are blocks of code that only execute if a certain condition that you define is met. Here is how they are written.

if(insert condition here)
{
  do this if condition is true;
}

The first thing to note is that there is NO SEMICOLON ON THE IF STATEMENT ITSELF. Be very careful not to put one there...it's a very easy error to miss when you're debugging your code.

Now onto the meat of this lesson - conditions. They go into the <insert condition here> part, and they are about what you'd expect. Equal to is written as "==", less than is "<", greater than is ">", less than or equal to is "<=", greater than or equal to is ">=", and lastly, not equal to is "!=". Simply place any one of these commands in between a number or variable, like so.

if(x == y)
{
  insert code here;
}

if(x != y)
{
  insert code here;
}

if(x >= y)
{
  insert code here;
}

if(x < y)
{
  insert code here;
}

C++ evaluates these statements just like they read: "If x equals y", "if x does not equal y", "if x is greater than or equal to y", and "if x is less than y" respectively.

What happens when conditional statements evaluate is fairly important. If the statement is not true, then it returns 0 or false, so it skips the code inside of the statement. If the statement is true, then it returns 1, which in "code language" means true. Technically, any number other than 0 is true, but it's easier to say 0 = false and 1 = true.

But that's not all she wrote on if statements. You can also nest them, or put one inside of another.

if(x != y)
{
  if(x > y)
  {
    If both conditions are true, do this;
  }
}

You can also use the ! symbol as a wildcard to make a statement return the opposite of what it actually is. Like so!

if(!(x == y)) 
{
  Do this if x does not equal y;            
}

If x equals y, then the condition will return 0 because of the ! in front of it.

Another level of all conditional statements (not just if statements) are combining conditions. That is, evaluating more than one condition within one if statement. This is done by way of the "&&" (AND), and "||" (OR) operators. With the AND operator, both conditions have to be true in order for it to return true. With the OR operator, only one has to be true. Again, C++ evaluates these statements just like they read:

if(1 == 1 && 2 == 2)
{
  Do this if both conditions are true;
}

"If 1 equals 1 AND 2 equals 2." True, because both statements are true.

if(1 == 2 && 2 == 2)
{
  Do this if both conditions are true;
}

"If 1 equals 2 AND 2 equals 2." False, because one of the statements is false.

if(1 == 2 || 2 == 2)
{
  Do this if either of the two conditions are true;
}

"If 1 equals 2 OR 2 equals 2." True, because one of the statements is true.

In addition to the initial if statement, you can also add on another statement to the end of it. That statement is the else statement. The code within an else statement only executes if the attached if statement evaluates to false. Consider this statement:

if(1 == 2)
{
  do this if it's true;
}else
{
  do this if it's false;
}

This would execute the code within the else statement. And with that, this lesson is complete.