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
What is %lu in c?
Explain a file operation in C with an example.
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What is getche() function?
What is null pointer in c?
What is the use of #define preprocessor in c?
Write a program to know whether the input number is an armstrong number.
What is ponter?
What happens if header file is included twice?
What does volatile do?
can we have joblib in a proc ?
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
#include
What is the use of a static variable in c?
What is the value of c?