# Half Adder using CNOT Gates

As per this schematic of qubits, how this explanation is correct --"If you look again at the four possible sums, you’ll notice that there is only one case for which this is 1 instead of 0: 1+1=10. It happens only when both the bits we are adding are 1.

The above attached snapshot is what I got after implementing the same. Kindly someone enlighten, whether I am implementing incorrectly, or the given explanation is incorrect.

• Hi and welcome to Quantum Computing SE. Your explanation is correct. But just one question: what is a purpose of fourth qubit? It seems not to be used. Sep 9, 2023 at 7:05
• Thanks for pointing out. Actually I just copied the qubit schematic demonstrated in qiskit tutorial and re-drawn in qiskit composer. As @** Egretta.Thula's ** explanation has made sense, so now I will use the 4th qubit to do AND operation for displaying carry. Sep 11, 2023 at 4:38

Half adder circuit provides two outputs, sum and carry. The circuit in your question computes the sum, while the text talks about the carry!

This statement:

If you look again at the four possible sums, you’ll notice that there is only one case for which this is 1 instead of 0: 1+1=10. It happens only when both the bits we are adding are 1.

is taken from this tutorial. The next few sentences in this tutorial describes how to compute the carry:

To calculate this part of the output, we could just get our computer to look at whether both of the inputs are 1. If they are — and only if they are — we need to do a NOT gate on qubit 3. That will flip it to the required value of 1 for this case only, giving us the output we need.

For this, we need a new gate: like a CNOT but controlled on two qubits instead of just one. This will perform a NOT on the target qubit only when both controls are in state 1. This new gate is called the Toffoli. For those of you who are familiar with Boolean logic gates, it is basically an AND gate.

In Qiskit, the Toffoli is represented with the ccx command.

The circuit after adding Toffoli gate should look like: