Docsity

Exam 01: Introduction to Computing and Computer Systems, Exams of Computer Programming

Toggle sidebar
bg1
Exam 03: Boolean Logic and Logic Gates Page 1
Exam 03: Boolean Logic and Logic Gates
Computer Science Exam Series | Time: 2 hours | Total: 84 marks
Answer all questions. Part A has 50 multiple choice questions (1 mark each). Part B has 8 short
answer questions (3 marks each). Part C has 2 longer questions (5 marks each). In Part A the
correct option is marked with a double tick. In expressions, A.B means A AND B, A+B means A OR
B and A' means NOT A. Answer key and model answers are at the end.
Part A: Multiple Choice (50 marks)
Q1. An AND gate outputs 1 when:
a) Any input is 1
b) All inputs are 1 โœ”โœ”
c) All inputs are 0
d) Exactly one input is 1
Q2. An OR gate outputs 1 when:
a) All inputs are 1
b) At least one input is 1 โœ”โœ”
c) All inputs are 0
d) Inputs are different
Q3. What is the output of a NOT gate when the input is 1?
a) 1
b) 0 โœ”โœ”
c) 2
d) Undefined
Q4. What is the output of a NAND gate with both inputs equal to 1?
a) 1
b) 0 โœ”โœ”
c) 2
d) Undefined
Q5. What is the output of a NOR gate with both inputs equal to 0?
a) 0
b) 1 โœ”โœ”
c) 2
d) Undefined
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Exam 01: Introduction to Computing and Computer Systems and more Exams Computer Programming in PDF only on Docsity!

Exam 03: Boolean Logic and Logic Gates

Computer Science Exam Series | Time: 2 hours | Total: 84 marks

Answer all questions. Part A has 50 multiple choice questions (1 mark each). Part B has 8 short answer questions (3 marks each). Part C has 2 longer questions (5 marks each). In Part A the correct option is marked with a double tick. In expressions, A.B means A AND B, A+B means A OR B and A' means NOT A. Answer key and model answers are at the end.

Part A: Multiple Choice (50 marks)

Q1. An AND gate outputs 1 when:

a) Any input is 1 b) All inputs are 1 โœ”โœ” c) All inputs are 0 d) Exactly one input is 1

Q2. An OR gate outputs 1 when:

a) All inputs are 1 b) At least one input is 1 โœ”โœ” c) All inputs are 0 d) Inputs are different

Q3. What is the output of a NOT gate when the input is 1?

a) 1 b) 0 โœ”โœ” c) 2 d) Undefined

Q4. What is the output of a NAND gate with both inputs equal to 1?

a) 1 b) 0 โœ”โœ” c) 2 d) Undefined

Q5. What is the output of a NOR gate with both inputs equal to 0?

a) 0 b) 1 โœ”โœ” c) 2 d) Undefined

Q6. What is the output of an XOR gate for inputs 1 and 0?

a) 0 b) 1 โœ”โœ” c) 2 d) Undefined

Q7. What is the output of an XOR gate for inputs 1 and 1?

a) 1 b) 0 โœ”โœ” c) 2 d) Undefined

Q8. What is the output of an XNOR gate for inputs 1 and 1?

a) 0 b) 1 โœ”โœ” c) 2 d) Undefined

Q9. How many rows does the truth table of a circuit with 3 inputs have?

a) 3 b) 6 c) 8 โœ”โœ” d) 9

Q10. How many rows does the truth table of a circuit with 4 inputs have?

a) 8 b) 12 c) 16 โœ”โœ” d) 4

Q11. What is A.0?

a) A b) 0 โœ”โœ” c) 1 d) A'

Q12. What is A+1?

a) A b) 0 c) A' d) 1 โœ”โœ”

Q20. According to De Morgan's law, (A+B)' equals:

a) A'+B' b) A'.B' โœ”โœ” c) A.B d) A+B'

Q21. Which gates are called universal gates?

a) AND and OR b) XOR and XNOR c) NAND and NOR โœ”โœ” d) NOT and AND

Q22. What is A XOR A?

a) 1 b) A c) 0 โœ”โœ” d) A'

Q23. What is A XOR 0?

a) A โœ”โœ” b) 0 c) 1 d) A'

Q24. What is A XOR 1?

a) A b) A' โœ”โœ” c) 0 d) 1

Q25. The distributive law states that A.(B+C) equals:

a) A.B + C b) A.B + A.C โœ”โœ” c) A+B.C d) (A+B).C

Q26. The absorption law states that A + A.B equals:

a) B b) A.B c) A โœ”โœ” d) A+B

Q27. A.(A+B) simplifies to:

a) A โœ”โœ” b) B c) A+B d) A.B

Q28. What is the value of (A.B)+C when A = 1, B = 0 and C = 1?

a) 0 b) 1 โœ”โœ” c) 2 d) Undefined

Q29. What is the value of (A+B)' when A = 0 and B = 0?

a) 0 b) 1 โœ”โœ” c) 2 d) Undefined

Q30. What is the value of A.B' when A = 1 and B = 0?

a) 0 b) 1 โœ”โœ” c) 2 d) Undefined

Q31. What is the value of (A XOR B).C when A = 1, B = 1 and C = 1?

a) 1 b) 0 โœ”โœ” c) 2 d) Undefined

Q32. A NAND gate with both inputs connected together acts as a:

a) AND gate b) OR gate c) NOT gate โœ”โœ” d) XOR gate

Q33. The sum output of a half adder is produced by which gate?

a) AND b) OR c) XOR โœ”โœ” d) NAND

Q41. Which expression represents XOR of A and B?

a) A.B + A'.B' b) A.B' + A'.B โœ”โœ” c) A.B d) (A+B)'

Q42. How many 1s appear in the output column of the truth table of a 2-input OR gate?

a) 1 b) 2 c) 3 โœ”โœ” d) 4

Q43. How many 1s appear in the output column of the truth table of a 2-input AND gate?

a) 1 โœ”โœ” b) 2 c) 3 d) 4

Q44. How many 1s appear in the output column of the truth table of a 2-input XOR gate?

a) 1 b) 2 โœ”โœ” c) 3 d) 4

Q45. A 2-input NAND gate outputs 0 only when:

a) Both inputs are 0 b) Both inputs are 1 โœ”โœ” c) The inputs differ d) Any input is 1

Q46. A 2-input NOR gate outputs 1 only when:

a) Both inputs are 1 b) The inputs differ c) Both inputs are 0 โœ”โœ” d) Any input is 1

Q47. A multiplexer:

a) Adds two binary numbers b) Selects one of several inputs to pass to the output using select lines โœ”โœ” c) Stores one bit of data d) Inverts its input

Q48. A decoder with n inputs has up to how many outputs, with exactly one active at a time?

a) n b) 2n c) 2 to the power n โœ”โœ” d) n squared

Q49. A flip-flop is used to:

a) Add numbers b) Store one bit of data โœ”โœ” c) Invert a signal d) Select between inputs

Q50. In a combinational circuit, the output depends on:

a) The current inputs only โœ”โœ” b) The current inputs and past inputs c) Only past inputs d) The clock only

Part B: Short Answer (24 marks)

S1. State De Morgan's two laws. [3]

S2. Give the output of A XOR B for each of the four input combinations (A, B) = (0,0), (0,1), (1,0), (1,1). [3]

S3. Explain why NAND is called a universal gate, and show how a NOT gate can be built from a NAND gate. [3]

S4. Describe the construction of a half adder. [3]

S5. Simplify A.B + A.B' + A'.B showing the Boolean laws used. [3]

Answer Key: Part A

Q Answer Q Answer Q Answer Q Answer Q Answer 1 b 11 b 21 c 31 b 41 b 2 b 12 d 22 c 32 c 42 c 3 b 13 c 23 a 33 c 43 a 4 b 14 a 24 b 34 a 44 b 5 b 15 c 25 b 35 b 45 b 6 b 16 b 26 c 36 b 46 c 7 b 17 a 27 a 37 b 47 b 8 b 18 d 28 b 38 b 48 c 9 c 19 b 29 b 39 a 49 b 10 c 20 b 30 b 40 c 50 a

Model Answers: Parts B and C

S1. (A.B)' = A' + B' (1 mark). (A+B)' = A'.B' (1 mark). In words, inverting an AND is the same as OR of the inverted inputs, and inverting an OR is the same as AND of the inverted inputs (1 mark). โœ”โœ” S2. (0,0) gives 0, (0,1) gives 1, (1,0) gives 1 and (1,1) gives 0. Award 3 marks for all four correct, 2 marks for three correct and 1 mark for two correct. โœ”โœ” S3. Any other gate or Boolean function can be built using only NAND gates (1 mark). Connecting both inputs of a NAND gate together gives A NAND A = A' (1 mark). Inverting the output of a NAND gives AND, and De Morgan's laws allow OR to be built, so all functions are possible ( mark). โœ”โœ” S4. A half adder adds two single bits A and B (1 mark). The sum output is A XOR B (1 mark). The carry output is A AND B (1 mark). โœ”โœ” S5. A.B + A.B' = A.(B + B') = A.1 = A (1 mark). The expression becomes A + A'.B (1 mark). By the absorption-type law A + A'.B = A + B, so the answer is A + B (1 mark). โœ”โœ” S6. Each input can be either 0 or 1, which is 2 possibilities (1 mark). Every additional input doubles the number of combinations (1 mark). So for n inputs the total number of combinations is 2 x 2 x ... x 2 (n times) = 2^n (1 mark). โœ”โœ” S7. The door must be open: D (1 mark). The second condition is an OR of two events: K' + W ( mark). Combined with AND, A = D.(K' + W) (1 mark). โœ”โœ” S8. In a combinational circuit the output depends only on the current inputs (1 mark), for example a half adder or multiplexer (1 mark). In a sequential circuit the output depends on current inputs and stored state or past inputs, for example a flip-flop or register (1 mark). โœ”โœ” L1. There are 8 rows. Listing ABC then Q: 000 gives 0; 001 gives 0; 010 gives 1; 011 gives 0; 100 gives 1; 101 gives 0; 110 gives 1; 111 gives 0. Award 1 mark for listing all 8 input combinations correctly, 1 mark for the column A + B, 1 mark for the column C', and 2 marks for the correct final column Q (1 mark if only one or two rows are wrong). โœ”โœ”

L2. Inputs are A, B and carry-in Cin; outputs are Sum and carry-out Cout (1 mark). Sum = A XOR B XOR Cin (1 mark). Cout = A.B + Cin.(A XOR B) (1 mark). For A = 1, B = 0, Cin = 1: A XOR B = 1, so Sum = 1 XOR 1 = 0 (1 mark). Cout = 1.0 + 1.1 = 1 (1 mark). So Sum = 0 and carry-out = 1, which matches 1 + 0 + 1 = 10 in binary. โœ”โœ”