Programm For Finding Binary Number Addition

Programm For Finding Binary Number Addition
———————————————————————


#include <stdio.h>
int main ()
{
  int a[6]={1,0,0,1,1,1},b[6]={1,1,0,1,1,0},c[7], carry=0, j;
  for(j=5;j>=0;j--)
   {
       c[j+1]=a[j]^b[j]^carry;
       carry = (a[j]*(b[j]^carry))+(b[j]*carry);
   }
  c[j+1]=carry;
  for (j=6;j>=0;j--)
   {
     printf ("%d",c[j]);
   }
return 0;
}
Advertisements

One thought on “Programm For Finding Binary Number Addition

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s