🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Computer Arithmetic: all 10 questions

Quiz: Computer Arithmetic · Question 9 of 10

What does this print? (code)

What does this print?

def full_adder(a, b, cin):
    s = a ^ b ^ cin
    cout = (a & b) | (cin & (a ^ b))
    return s, cout

print(full_adder(1, 0, 1), full_adder(1, 1, 1))
  1. A.(1, 0) (1, 1)
  2. B.(0, 1) (1, 1)
  3. C.(0, 1) (0, 1)
  4. D.(1, 1) (1, 0)
Answer & explanation

Correct answer: (0, 1) (1, 1)

1 + 0 + 1 = 2 = binary 10 (sum 0, carry 1); 1 + 1 + 1 = 3 = binary 11 (sum 1, carry 1).

Can you get the rest right without peeking?

Take the timed Quiz: Computer Arithmetic quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →