Types of Decisional Statements
Let's learn about conditional statements.
We'll cover the following...
Decision-making is an important part of computer programs. The if
, else if
, and else
statements identify which statement to run based on the Boolean value of an expression.
The if
condition
The code in an if
statement only executes if the condition is true. In the example below, there’s an if
statement with an equality operator of ==
.
Example: Print Today is Monday
if the value of todaysDay
is Monday
.
Press + to interact
string todaysDay = "Monday";if (todaysDay == "Monday" ){// Code within the curly brackets will execute because Monday equals Monday is TRUEConsole.WriteLine("Today is Monday");}
In the lesson ...