Locked lesson.
About this lesson
In this lesson, we learn how to use "And" operators within an If/Else statement.
Exercise files
Download this lesson’s related exercise files.
32 - Logic If else And Operators.docx61.4 KB 32 - Logic If else And Operators SOLUTION.docx
58.6 KB
Quick reference
Logic: If/else And Operators
The if/else and operator && allows you to make more than one comparison. All must be true to evaluate true.
When to use
Use this whenever you need to compare more than one thing and all of them need to be true.
Instructions
int a,b;
a = 20;
b = 19;
if (a > b && a < 100)
{
Console.WriteLine($"{a} is Greater than {b} and less than 100");
}
Hints & tips
- && // and operator
- With an && operator, ALL conditions must be true for the if statement to evaluate to true
Lesson notes are only available for subscribers.