Semester Project: Truth Table Generator
Tuesday, December 21, 2021
The Truth Table Generator is a C++ program that utilizes object-oriented programming and data structures to generate a truth table for a provided logical expression. The program supports the following logical operators: NOT, AND, and OR. It also includes the ability to resolve brackets using a stack, resulting in a postfix expression.
Features
- Logical expression evaluation: The program can evaluate logical expressions containing NOT, AND, and OR operators.
- Bracket resolution: The program can handle expressions with brackets by resolving them using a stack and converting the expression to postfix notation.
- Truth table generation: Given a logical expression, the program generates a truth table with all possible combinations of inputs and the corresponding output values.
- User-friendly interface: The program provides a user-friendly interface to input the logical expression and view the generated truth table.
Getting Started
To use the Truth Table Generator, follow these steps:
1. Clone the repository or download the source code files.
https://github.com/Muneeb1030/Truth-Table-Generator-Data-Structures-Cpp.git
2. Open the terminal and navigate to the project directory.
3. Compile the source code using a C++ compiler:
g++ truth_table_generator.cpp -o truth_table_generator
4. Run the program:
./truth_table_generator
5. Follow the instructions provided by the program to enter the logical expression.
6. View the generated truth table.
Requirements
The Truth Table Generator requires a C++ compiler that supports C++11 or higher.
Usage
1. Input the logical expression following the provided syntax guidelines:
- Use '~' for NOT operator.
- Use '^' for AND operator.
- Use '|' for OR operator.
- Enclose sub-expressions in brackets '(' and ')'.
- Use uppercase letters for variables.
- Separate each expression or variable with spaces.
Example: (~A ^ B) | (C ^ D)
2. Press Enter to generate the truth table.
3. The program will display the truth table showing all possible combinations of inputs and the corresponding output values.