#include<stdio.h> int BitSwapReqd(int A, int B); { int tmp=1, count=0; while(A || B) { if(A&1 != B&1) count++ A=A>>1; B=B>>1; } return count; }
int main() { int a,b; printf("Enter the Value of A & B\n"); scanf("%d%d",&a,&b); printf("these no of bits required to convert from A to B = %d \n",BitSwapReqd(a,b)); return 0; } On Aug 16, 10:39 pm, richa gupta <richa.cs...@gmail.com> wrote: > Given two integers A & B. Determine how many bits required to convert > A to B.how to write a function int BitSwapReqd(int A, int B); > > -- > Richa Gupta > (IT-BHU,India) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---