rev='made'/> name='keywords'/> name='author'/> ANURANAN: UVa Solution 10931:Parity

Welcome Note

Hi,
I'm Anisuzzaman Babla . I am a full stack Android Application Developer. I am working with Android for more than two years. I have completed my graduation from IIT, Jahangirnagar University. I have developed a series of commercially successful apps on Android. Moreover, 10+ of my Apps are live at Google play store. .
Thank You

UVa Solution 10931:Parity

    #include<stdio.h>

    int main()
    {
    long int num;
    int bin[1001],i,j,bit,len;
    while(scanf("%ld",&num)==1)
    {
    if(num<1) break;
    len=1;
    bit=0;
    for(i=1;i<=200;i++)
    {
    bin[i]=num%2;
    if(bin[i]==1) bit++;
    num=num/2;
    if(num==0) break;
    len++;
    }
    printf("The parity of ");
    for(j=len;j>=1;j--)
    {
    printf("%d",bin[j]);
    }
    printf(" is %d (mod 2).\n",bit);

    }
    return 0;
    }

1 comment:

  1. can you explain this to me, as I can't understand it at all

    ReplyDelete