Lesson 10 of 15
Full Adder
Full Adder
A full adder adds three bits: two inputs A, B, and a carry-in (Cin). It produces a sum and a carry-out (Cout).
| A | B | Cin | Sum | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The full adder is built from two half adders:
step1 = halfAdder(A, B) → {sum: s1, carry: c1}
step2 = halfAdder(s1, Cin) → {sum: S, carry: c2}
Cout = c1 OR c2
Your Task
Implement fullAdder(a, b, cin) that returns { sum, carry }. Use your half adder internally.
JavaScript loading...
Loading...
Click "Run" to execute your code.