Add decision logic to your code using the if-elseif-else statement in C#


Learn to branch your code's execution path by evaluating boolean expressions.

Learning objectives

In this module, you will:

  • write code that evaluates conditions using the if-elseif-else statements
  • build boolean expressions to evaluate a condition
  • combine boolean expressions using logical operators
  • nest code blocks within other code blocks


  • Experience declaring, initializing, setting, and retrieving variables using the int data type
  • Experience printing messages to output using Console.WriteLine()
  • Experience with string interpolation to combine variables into literal strings
  • Experience working with the System.Random class to generate random numbers