C program to find Binary Addition and Binary Subtraction
Binary addition/subtraction is similar to regular (daily life) addition/subtraction, but here addition/subtraction performs only two digits those are 0 and 1, these are binary digits hence such kind of addition/subtraction is called binary addition/subtraction.
Example of Binary Addition:
Take two numbers, suppose numbers are 10 and 20 their binaries are 1010 and 10100.
In binary addition
0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 0 (1 carries out)
Now add 10 and 20
10 = 0 1 0 1 0
20 = 1 0 1 0 0
= 1 1 1 1 0
= 30
Example of Binary Subtraction:
Take two numbers, suppose numbers are 20 and 10 their binaries 10100 and 1010.
In binary subtraction
0-0 = 0
1-0 = 1
0-1 = 1 (1 borrows out)
1-1 = 0
Now sub 10 from 20
20 = 1 0 1 0 0
10 = 0 1 0 1 0
= 0 1 0 1 0
= 10
Consider the example:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer