Question: Your program takes as input a 3 - variable Boolean function in the form of a sum - of - products. For example, the input
Your program takes as input a variable Boolean function in the form of a
sumofproducts. For example, the input can look like ABABC
ABC The double quotations are needed so that the is taken as
a regular character, negating the preceding variable, and not considered a
special character.
The evaluation of each term, eg ABC is done in a separate function,
called, evalTermint A int B int C char term that return the
Boolean value or of the corresponding term.
Your program should print the Boolean function followed by its truth
table.
#include
#include
Function to evaluate a single term
int evalTermint A int B int C char term
int result ;
for int i ; i strlenterm; i
if termiA && A
result ;
break;
else if termiB && B
result ;
break;
else if termiC && C
result ;
break;
return result;
Function to print the truth table
void printTruthTablechar function
int A B C;
printfTruth table of F
function;
printfA B C F
;
printf
;
for A ; A ; A
for B ; B ; B
for C ; C ; C
int result ;
int numTerms ; Count the number of terms
char term strtokfunction;
while term NULL
result evalTermA B C term;
numTerms; Increment the term count
term strtokNULL;
printfd d d d
A B C result numTerms : ;
int mainint argc, char argv
if argc
printfTruth table generator for variable Boolean functions
argv;
printfUsage:Enter a Boolean function as a sum of products
argv;
return ;
printTruthTableargv;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
