Menu
Coddy logo textTech

Recap - Simple Logic

Part of the Fundamentals section of Coddy's C# journey — lesson 23 of 69.

challenge icon

Challenge

Beginner

Given the following code snippet, your task is to assign boolean values (true or false) to variables b1, b2, and b3 so that b4 evaluates to true.

The variable b4 is calculated using the following logic:

  • It performs an AND operation (&&) between b1, b2, and the NOT of b3
  • For b4 to be true, all parts of the AND operation must be true

Try it yourself

using System;

public class Program {
    public static void Main(string[] args) {
        bool b1 = ?;
        bool b2 = ?;
        bool b3 = ?;
        
        bool b4 = b1 && b2 && (!b3);
        Console.WriteLine("b4 = " + b4);

    }
}

All lessons in Fundamentals