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...

Write a program to display the no of bit difference between
any 2 given numbers
eg: Num1 will 12->1100
Num2 will 7->0111 the difference in bits are 2.

Answer Posted / banavathvishnu

int main()
{
int num1,num2;
int cnt = 0;
int temp1,temp2;
printf("enter 2 numbers \n");
scanf("%d %d",&num1,&num2);
while((num1!=0)||(num2!=0))
{
temp1= num1 & 0x01;
temp2 = num2 & 0x01;
if((temp1 ^ temp2)==1)
cnt++;
num1 = num1>>1;
num2 = num2>>1;
}
printf("difference is %d",cnt);
getch();
}

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain bit masking in c?

1079


Why is c called c?

950


What is the purpose of main( ) in c language?

1085


What is a macro?

1047


What is the use of getchar functions?

1125


What does it mean when the linker says that _end is undefined?

1037


In c language can we compile a program without main() function?

1056


How many levels deep can include files be nested?

1095


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

2032


What is a keyword?

1119


What are the types of pointers in c?

970


What are the 4 types of programming language?

1046


What is an lvalue?

1013


How is actual parameter different from the formal parameter?

973


hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm

1965