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 / subhash

void main()
{
unsigned int a, b, c;
int count = 0;

printf("Enter 2 numbers:");
scanf("%d %d", &a, &b);

c = a ^ b; /* "c" holds bits set for different bits
in "a" and "b" *
/
while(c)
{
c &= (c-1);
count++;
}

printf("The different bits set:%d", count);
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is %lu in c?

1257


Explain a file operation in C with an example.

1119


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

2180


What is getche() function?

1043


What is null pointer in c?

990


What is the use of #define preprocessor in c?

1079


Write a program to know whether the input number is an armstrong number.

1122


What is ponter?

1265


What happens if header file is included twice?

1150


What does volatile do?

980


can we have joblib in a proc ?

2303


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

1095


#include int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

1724


What is the use of a static variable in c?

1062


What is the value of c?

1065