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 / kapil singhal

#include<stdio.h>
main()
{
int n1,n2,i=0,kap=0,k=0,j,temp;
int sum[100];

printf("Enter first binary no. : ");
scanf("%d",&n1);

printf("Enter second binary no. : ");
scanf("%d",&n2);

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

i++;

}
if(n1==0 && n2==0){
sum[i]=k;

}
for(j=0;j<=i/2;j++){
temp=sum[j];
sum[j]=sum[i-j];
sum[i-j]=temp;
}
printf("Sum is : ");
for(j=0;j<=i;j++){
printf("%d",sum[j]);
}
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is page thrashing?

1140


What is the difference between functions abs() and fabs()?

1207


What is define c?

1154


Explain what is the difference between the expression '++a' and 'a++'?

1262


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

1261


will u please send me the placement papers to my mail???????????????????

1883


By using C language input a date into it and if it is right?

1132


What does dm mean sexually?

1381


What are static variables in c?

1128


What is a stream?

1192


Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

1154


How many identifiers are there in c?

1081


What language is lisp written in?

1320


How do you redirect a standard stream?

1150


What is the use of in c?

1085