Saturday, March 31, 2012

Program for counting number of Parity Bits in an integer.

Program for counting number of Parity Bits in an integer.

main()
{
       int num, cnt = 0;

       printf("enter the no :");
       scanf("%d",&num);

       while (num != 0)
       {
             num = num & (num - 1);
             cnt++;
       }

       printf("
 number of parity bits = %d ",cnt);
}

No comments:

Post a Comment