82 / 100

Program To Add Binary Number

Hey learner, In this tutorial we are going to program for the sum of Binary Number in C, So if you want to learn then, follow the below code. So lets start the Add Binary Number Program.

Program for sum of binary number in c

In C programming, the Program to add Binary number is so easy, First of all take two binary number in integer, and then use one and one digit from right side by using mod operation. and add them if the sum of binary number is 10, then 1 should be reminder and take that reminder in the second digit sum. And so on.

Sum of two binary number
Sum of two binary number

Program in C

int main()
	int sum[10], binary1,binary2;
	int i=0, rem =0;
	printf("Enter the first binary number : ");
	printf("Enter the second binary number : ");
	while(binary1!=0 || binary2!=0)
		sum[i++] = (binary1%10 + binary2%10 + rem)%2;
		rem = (binary1%10 + binary2%10)/2;
		binary1 = binary1/10;
		binary2 = binary2/10; 
		sum[i++] = rem;
	printf("The sum of binary Number is : ");
	return 0;

Video Tutorial for adding Binary Number in C

Learn More Python Tutorials

If you have any queries regarding Program Sum of Binary Number In C, then ask in the comment section, I am happy to answer your question. And If You got some benefits from this article then please share it with your friends.

4 thoughts on “Program To Add Binary Number”

Leave a Comment

Share via
Copy link
Powered by Social Snap