The CNOT gate is two-qubit operation, where the first qubit is usually referred to as the control qubit and the second qubit as the target qubit. Expressed in basis states, the CNOT gate:
- leaves the control qubit unchanged and performs a Pauli-X gate on the target qubit when the control qubit is in state ;
- leaves the target qubit unchanged when the control qubit is in state .
version 1.0 qubits 2 H q # execute Hadamard gate on qubit 0 to create a superposition state CNOT q, q # entangle both qubits using CNOT gate