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

What is const keyword in c?

1221


How does normalization of huge pointer works?

1232


What are the application of c?

1165


Explain the difference between malloc() and calloc() in c?

1104


How do you print only part of a string?

1073


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

2066


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3568


Explain how are portions of a program disabled in demo versions?

1174


Compare array data type to pointer data type

1085


What are dangling pointers? How are dangling pointers different from memory leaks?

1394


What is bss in c?

1164


What are run-time errors?

1179


Write a program to print “hello world” without using semicolon?

1185


What is pivot in c?

1079


What does == mean in texting?

1395