Add decision logic to your code using `if`, `else`, and `else if` statements in C#

Beginner
Developer
Student
.NET

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 if, else, and else if statements.
  • Build Boolean expressions to evaluate a condition.
  • Combine Boolean expressions using logical operators.
  • Nest code blocks within other code blocks.

Prerequisites

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