Ch 6. Boolean Algebra and Combinatorial Circuits

Ch 6. Programming Exercises

Exercise 1: Logic Gate Simulator

The objective of this exercise is to simulate basic logic gates.

Write a program (using pseudocode or a programming language of your choice) that takes two binary inputs and simulates the behaviour of AND, OR, and NOT gates. Display the output for each gate.

 

Exercise 2: Truth Table Generator

The objective of this exercise is to generate truth tables for Boolean functions.

Create a program (using pseudocode or a programming language of your choice) that accepts a Boolean expression (e.g., [latex]A \cdot B + \bar{C}[/latex]) and outputs the complete truth table for all input combinations. Include input validation and support for up to three variables.

 

Exercise 3: Boolean Expression Simplifier

The objective of this exercise is to apply Boolean algebra laws.

Write a program (using pseudocode or a programming language of your choice) that takes a Boolean expression and simplifies it using identity, complement, and distributive laws. Include comments explaining each simplification step.

 

Exercise 4: Circuit Evaluator

The objective of this exercise is to evaluate Boolean functions based on input values.

Create a program (using pseudocode or a programming language of your choice) that defines a Boolean function (e.g., [latex]F(A, B, C) = (A \cdot B) + C[/latex]) and evaluates it for user-provided binary inputs. Display the result and explain the logic used.

 

Exercise 5: Smart System Logic Builder

The objective of this exercise is to model a real-world system using Boolean logic.

Simulate a smart home system that turns on the heater if the temperature is low and the user is home, or if the manual override is enabled.

Inputs: [latex]T[/latex]: Temperature low, [latex]H[/latex]: User home, [latex]O[/latex]: Override enabled

Output: Heater status

Write the Boolean function and implement it in code (using pseudocode or a programming language of your choice). Display the output based on user input.