Beispiel #1
0
// this function ask the user for a number to calculate the number of odd bits
int main() {
  unsigned long test;
  printf("Please enter number to check: ");
  scanf("%lu",&test);
  printf("\nnumber of odd bits (in %lu) are: %d\n",test,count_odd_bits(test));
  return(0);
}
Beispiel #2
0
int divby3(int x) {
    int n = count_even_bits(x) - count_odd_bits(x);
    switch(n) {
    case 0:
    case 3:
    case 5:
    case 6:
    case 9:
    case 12:
    case 15:
    case 18:
    case 21:
    case 24:
    case 27:
    case 30:
        return 1;
    default:
        return 0;
    }
}