Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to print the truth table for the following propositional sta

ID: 3853300 • Letter: W

Question

Write a C++ program to print the truth table for the following propositional statement using the variables a, b, c, d, e:

(( c V ~d ) A b ) A ~( d V a A e )

Note: V represents OR, A represents AND, ~ represents NOT

The truth table should include 6 columns: a, b, c, d, e and answer.

Output should contain 33 rows:

The first row should display column headers (using the correct symbols). The last 32 rows should contain the values of the truth table.

To make this program easier to read and grade, format the 5 propositional variables as follows:

a: toggle between 16 T then 16 F

b: toggle between eight T then eight F

c: toggle between four T then four F

d: toggle between two T then two F

e: toggle between one T then one F

Do not hardcode the truth values. They must be calculated.

Explanation / Answer

Here is the code and output for the question. Please rate the answer if it helped. Thank you.

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

bool values[] = {true, false};

bool a, b, c, d, e , propo;

int row = 0;

  

cout << boolalpha; //to display true false

  

cout << "Displaying the truth table for the proposition (( c V ~d ) A b ) A ~( d V a A e ) " << endl << endl;

cout << "row a b c d e proposition " << endl << endl;

  

for(int m = 0; m < 2; m++)

{

a = values[m];

  

for(int l = 0; l < 2; l++)

{

b = values[l];

for(int k = 0; k < 2; k++)

{

c = values[k];

for(int j = 0; j < 2; j++)

{

d = values[j];

for(int i = 0; i < 2; i ++)

{

e = values[i];

propo = (( c | !d ) & b ) & !( d | a & e );

row++;

cout << setw(2) << row << ". " << a << " " << b << " " << c << " " << d << " " << e << " " << propo << endl;

}

}

}

  

}

}

}

output

Displaying the truth table for the proposition (( c V ~d ) A b ) A ~( d V a A e )

row    a        b        c        d        e        proposition

1.    true   true   true   true   true   false

2.    true   true   true   true   false   false

3.    true   true   true   false   true   false

4.    true   true   true   false   false   true

5.    true   true   false   true   true   false

6.    true   true   false   true   false   false

7.    true   true   false   false   true   false

8.    true   true   false   false   false   true

9.    true   false   true   true   true   false

10.    true   false   true   true   false   false

11.    true   false   true   false   true   false

12.    true   false   true   false   false   false

13.    true   false   false   true   true   false

14.    true   false   false   true   false   false

15.    true   false   false   false   true   false

16.    true   false   false   false   false   false

17.    false   true   true   true   true   false

18.    false   true   true   true   false   false

19.    false   true   true   false   true   true

20.    false   true   true   false   false   true

21.    false   true   false   true   true   false

22.    false   true   false   true   false   false

23.    false   true   false   false   true   true

24.    false   true   false   false   false   true

25.    false   false   true   true   true   false

26.    false   false   true   true   false   false

27.    false   false   true   false   true   false

28.    false   false   true   false   false   false

29.    false   false   false   true   true   false

30.    false   false   false   true   false   false

31.    false   false   false   false   true   false

32.    false   false   false   false   false   false

Program ended with exit code: 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote