-
Notifications
You must be signed in to change notification settings - Fork 15
/
TTGen.pas
56 lines (48 loc) · 1.16 KB
/
TTGen.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
program TruthTableGenerator;
uses
crt;
// Generates the truth table for the logical AND operation
procedure GenerateANDTable;
var
A, B: Boolean;
begin
Writeln('A B | A AND B');
Writeln('-------------');
for A := False to True do
for B := False to True do
Writeln(A:5, B:3, ' | ', A and B:7);
end;
// Generates the truth table for the logical OR operation
procedure GenerateORTable;
var
A, B: Boolean;
begin
Writeln('A B | A OR B');
Writeln('------------');
for A := False to True do
for B := False to True do
Writeln(A:5, B:3, ' | ', A or B:6);
end;
// Generates the truth table for the logical NOT operation
procedure GenerateNOTTable;
var
A: Boolean;
begin
Writeln('A | NOT A');
Writeln('---------');
for A := False to True do
Writeln(A:5, ' | ', not A:6);
end;
begin
// Generate truth tables for AND, OR, and NOT
Writeln('Truth Table for AND:');
GenerateANDTable;
Writeln; // Blank line for separation
Writeln('Truth Table for OR:');
GenerateORTable;
Writeln; // Blank line for separation
Writeln('Truth Table for NOT:');
GenerateNOTTable;
// Prevent console window from closing immediately
Readln;
end.