if, if-else, if-else if

If Statements

  • If something is true/false, the next is done.

int marks = 77;

if (marks > 50)
{
    Console.WriteLine("PASS");
}
  • If marks greater than 50, then pass. Nothing is done in any other scenario.

If-else Statements

  • If true/false do one thing, otherwise do something else.

int marks = 77;

if (marks > 50)
{
    Console.WriteLine("PASS");
}
else
{
    Console.WriteLine("FAIL");
}

If-else if Statements

  • Handles multiple conditional statements

Last updated