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 pointers in c?

1169


Disadvantages of C language.

1166


Differentiate Source Codes from Object Codes

1665


Write a program to swap two numbers without using third variable?

1351


how to count no of words,characters,lines in a paragraph.

4472


What does calloc stand for?

1246


What is null in c?

1157


What is getche() function?

1089


formula to convert 2500mmh2o into m3/hr

1051


Write the syntax and purpose of a switch statement in C.

1153


Explain what are global variables and explain how do you declare them?

1235


Why pointers are used in c?

1072


What are the application of c?

1163


Define VARIABLE?

1238


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

2069