Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

c programming of binary addition of two binary numbers

Answer Posted / leon

#include<stdio.h>
#include<conio.h>
int main()
{
long int n1,n2,r=0,sum[50];
int n,i=0;
clrscr();
printf("\n\n Enter First Binary Number: ");
scanf("%ld",&n1);
printf("\n\n Enter Second Binary Number: ");
scanf("%ld",&n2);

while (n1!=0 || n2!=0)
{
sum[i++]=(n1%10+n2%10+r)%2;
r=(n1%10+n2%10+r)/2;
n1=n1/10;
n2=n2/10;
}
if(r!=0)
sum[i++]=r;

printf("\n\n Sum of two binary numbers: ");

for(i=i-1;i>=0;i--)
printf("%d",sum[i]);

getch();
return 0;
}

Is This Answer Correct ?    17 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1048


how is the examination pattern?

1965


What is c language and why we use it?

1004


Hi can anyone tell what is a start up code?

2000


What is output redirection?

1165


write a program to find out prime number using sieve case?

2037


Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon

2231


What are high level languages like C and FORTRAN also known as?

1106


In C programming, what command or code can be used to determine if a number of odd or even?

990


what does static variable mean?

1050


Can you mix old-style and new-style function syntax?

1048


What is c value paradox explain?

1020


What is difference between function overloading and operator overloading?

1046


Can you tell me how to check whether a linked list is circular?

1325


What is the difference between a string and an array?

1153