Create a program that can try out every possible logical combination of the vari
ID: 3662287 • Letter: C
Question
Create a program that can try out every possible logical combination of the variables A, B, and C, and determine which combinations will yield a true statement. A few things to take note of, first there are eight different possible combinations of the three variables. Make certain you test all eight of the combinations. The code itself will account for 50pts. Include the combinations of A, B, and C that cause the statement to be true for an additional 50pts.
(1) (A and B) or (A and C)
(2) (A and C) and (B and !C)
(3) (A or B) and !(B or C)
(4) (A or (B and C)) and (!C and !B)
(5) ((B and C) or (C and A)) and (!(A or B) and C)
Explanation / Answer
#include<iostream.h>
#include<conio.h>
void main()
{
int a=2,b=3,c=5;
if((a&c)|(a&c))
{
cout<<"True";
}
if((a&c) & (b&!c))
{
cout<<"True";
}
if((a|c) & !(b|c))
{
cout<<"True";
}
if((a|(b&c)) & (!c&!b))
{
cout<<"True";
}
if(((b&c) | (c&a)) & (!(a|b)&c))
{
cout<<"True";
}
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.