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

Please write the code in C++ Prog1 - Truth tables Write a program that produces

ID: 3875856 • Letter: P

Question

Please write the code in C++

Prog1 - Truth tables Write a program that produces the truth table of the following logical operators. You can output one table with all the operators (one column for each operator) or five tables (one table for each operator), you decide. Write the header(s) of the table(s)- this is the name of the columns-. Output the result on the file prog1 output.txt. The table should contain the letters ’T’ and ’F’, it should not print 1s and 0s. Show the results on the following order: 1. negation 2. disjunction (AND operator) 3. conjunction (OR operator)

Output.txt

Explanation / Answer

As per your requirement the below one is solution please follow it

#include<iostream.h>

#include<conio.h>

#include <fstream.h>

void main()

{

clrscr();

int a=0;

b=1,

c;

cout<<"enter value of a=(0/1)";

cin>>a; cout<<"enter value of b=(0/1)";

cin>>b; cout<<" enter 1 for negation";

cout<<" enter 2 for disjuction";

cout<<" enter 3 for conjuction";

cout<<" enter 4 for exclusive";

cout<<" enter your choice=";

int choice; cin>>choice;

switch(choice)

{

case 1: c=!a;

break;

case 2:

c=a&&b;

break;

case 3:

c=a||b;

break;

case 4:

c=a^b;

break;

}

Ofstream ofobj("output.txt");

Char ch[30];

if(c==1)

{

cout<<"true";

}

else if(c!=1)

{

cout<<"false";

}

Ofobj<<ch: Ofobj. Close();

getch();

}