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 FIFO?

1728


What does a function declared as pascal do differently?

1137


Can main () be called recursively?

1124


What does c mean in basketball?

998


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1254


What is scanf_s in c?

1125


What is union in c?

1119


Differentiate fundamental data types and derived data types in C.

1036


Can two or more operators such as and be combined in a single line of program code?

1375


Is flag a keyword in c?

1155


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

1110


What is scope and lifetime of a variable in c?

1074


Is linux written in c?

1040


What is the use of #include in c?

1087


Explain setjmp()?

1074