Exercises: More Complex Conditions

Now let's exercise our new skills with complex conditions. Let's solve a few practical tasks.

Video: Chapter Summary

Watch this video to review what we learned in this chapter: https://youtu.be/QOhyJXZ0HHQ.

What We Learned in This Chapter?

Before proceeding ahead, let's remind ourselves about the new program constructs and techniques that we have learned in this chapter.

Nested Conditions

if (condition1)
{
if (condition2)
// body;
else
// body;
}


Complex Conditions with &&, ||, ! and ()

if ((x == left || x == right) && y >= top && y <= bottom)
Console.WriteLine(…);


Switch-Case Conditions

switch (selector)
{
case value1:
construction;
break;
case value2:
case value3:
construction;
break;
…
default:
construction;
break;
}


The Exercises

Solve the exercises below to learn how to work with nested and more complex conditions: