#include<stdio.h>

main()
{

unsigned num;
int ctr=0;
printf("Enter the number: ");
scanf("%d",&num);

while(num)
{
    if( (num & 1) && ((num >> 1) & 1) )
    {
        ctr++;
        num>>=1;
    }
    else
    {
        num>>=1;
    }
}

printf("number of pair: %d ",ctr);

}
On Fri, Jul 23, 2010 at 12:39 AM, vijay <auvija...@gmail.com> wrote:

> Get the number of pairs of “ones” in a given integer. Eg: if the
> integer is 7 (binary: 0111), then the number of pairs of ones is 2
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
regards

Apoorve Mohan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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?hl=en.

Reply via email to