Chapter 3.2. Simple Conditions – Exam Problems

In the previous chapter, we went through the simple conditional statements in C#, which we can use to execute different actions depending on a given condition. We mentioned what the scope of a variable is, and how to track the execution of our program step by step (the so-called debugging) as well. In this chapter, we will practice working with simple conditions by going through some exam tasks. To do this, let's first revise their construction:

if (bool expression)
    // condition body;
    // else-construction body;

if conditions consist of:

  • if clause
  • bool expression – a variable of bool type (bool) or bool logical expression (an expression that results in true/false)
  • condition body – contains random block of source code
  • else clause and its block of source code (optional)

Exam Problems

After having revised how to write simple conditions, let' s solve a few exam problems in order to practice the if-else construction:

results matching ""

    No results matching ""