Locked lesson.
About this lesson
We introduce If/Else Statements and look at how they run inside a program.
Exercise files
Download this lesson’s related exercise files.
31 - Logic If else Statements.docx61.3 KB 31 - Logic If else Statements SOLUTION.docx
58.7 KB
Quick reference
Logic: If/Else Statements
If/Else Statements allow us to make decisions in our code.
When to use
Use them whenever you need to make a decision in your code.
Instructions
int a,b
a = 20;
b = 19;
if (a > b)
{
Console.WriteLine($"{a} is Greater Than {b}");
}
else
{
Console.WriteLine($"{a} is Not Greater Than {b}");
}
Hints & tips
- If/Else Statements allow you to make decisions and take action based on those decisions.
Lesson notes are only available for subscribers.