0% found this document useful (0 votes)
4 views

Module3 - Assignment Sheet1

The document contains a Boolean assignment focusing on truth tables, with three questions addressing logical expressions and their evaluations. It includes examples of truth tables for various logical conditions involving department numbers and conditions for printing values based on specified criteria. The assignment emphasizes the understanding of logical operators and their application in programming logic.

Uploaded by

snrprintinginc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Module3 - Assignment Sheet1

The document contains a Boolean assignment focusing on truth tables, with three questions addressing logical expressions and their evaluations. It includes examples of truth tables for various logical conditions involving department numbers and conditions for printing values based on specified criteria. The assignment emphasizes the understanding of logical operators and their application in programming logic.

Uploaded by

snrprintinginc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Module

 3
Boolean  Assignment  -­‐  Truth  Tables
Ravi  Patel  -­‐  Student  ID#

Question  1)

~(A  OR  B)  AND  C


!(A  ||  B)  &&  C

A B C (A  ||  B) ~(A  ||  B) ~(A  ||  B)  &&  C


F F F F T F
F F T F T T
F T F T F F
F T T T F F
T F F T F F
T F T T F F
T T F T F F
T T T T F F

Question  2)

a)
The  program  terminates  when  the  department  number  is  invalid
(valid  numbers  are  between  0  and  100,  exclusive  (meaning,  not  including  0  and  100))
OR  we  reach  the  end  of  the  file.  When  counter  is  invalid,  it  is  <=  0  OR  >=  100.

Let  A  =  department_number  <  =  0


Let  B  =  department_number  >  =  100
Let  C  =  Reach  the  end  of  the  file

A  OR  B  OR  C
A  V  B  V  C
b)
A B C A  V  B  V  C
F F F F
F F T T
F T F T
F T T T
T F F T
T F T T
T T F T
T T T T

We  can  see  by  the  final  column  that  the  expression  is  true  for  all  rows  except  for  row  1:
when  A  or  B  or  C  are  true.  One  has  to  be  true  for  the  program  to  terminate.
For  all  other  cases,  the  end  result  if  false.  Therefore,  our  process  terminates  when  we  reach
the  end  of  the  file,  or  when  counter  is  either  less  than  or  equal  to  0,  or  greater  than  or  equal
 to  100.

Question  3)
Print  x  when  x  is  between  1  and  5  inclusive  or  is  an  odd  number.
Expression  -­‐   (  B  AND  C  )  OR  (  NOT  D  )  
(  B  ^  C  )  V  (  !D  )

Print  x  when  x  isn't  a  prime  number,  is  between  1  and  5  inclusive,  and  is  odd.
Expression  -­‐ (  NOT  A  )  AND  (  B  AND  C  )  AND  (  NOT  D)
(  !A  )  ^  (  B  ^  C  )  ^  (  !D  )

Print  x  when  x  is  less  than  1  or  is  an  odd  number  greater  than  5.
Expression  -­‐ (  NOT  B  )  OR  (  NOT  C  AND  NOT  D  )
(  !B  )  V  (  !C  ^  !D  )

You might also like