If/Else Statements

if and else statements allow decision-making in programs.

int age = 18;
if (age >= 18) {
  cout << "You are an adult.";
} else {
  cout << "You are a minor.";
}

You can also use else if to check multiple conditions.

← PrevNext →