C++ program to implement Full Adder
Prerequisite : Full Adder
We are given three inputs of Full Adder A, B,C-IN. The task is to implement the Full Adder circuit and Print output i.e. sum and C-Out of three inputs.
A Full Adder is a combinational circuit that performs an addition operation on three 1-bit binary numbers. The Full Adder has three input states and two output states. The two outputs are Sum and Carry.
Here we have three inputs A, B, Cin and two outputs Sum, Cout. And the truth table for Full Adder is
Logical Expression :
SUM = C-IN XOR ( A XOR B )
C-0UT= A B + B C-IN + A C-IN
- Input : A=1, B=0,C-In=0
Output : Sum=1, C-Out=0
Here from logical expression Sum= C-IN XOR (A XOR B ) i.e. 0 XOR (1 XOR 0) =1 , C-Out= A B + B C-IN + A C-IN i.e., 1 AND 0 + 0 AND 0 + 1 AND 0 = 0 .
- Input : A=1, B=1,C-In=0
Output: Sum=0, C-Out=1
- Initialize the variables Sum and C_Out for storing outputs.
- First we will take three inputs A ,B and C_In.
- By applying C-IN XOR (A XOR B ) we get the value of Sum.
- By applying A B + B C-IN + A C-IN we get the value of C_Out.
Sum = 1 C-Out = 0