ProgrammingHardCompetitive coding (CP)

How many integers from 1 to 64 have their low three bits all clear? Compute with this program.

How many integers from 1 to 64 have their low three bits all clear? Compute with this program.
#include <stdio.h>
int main(void) {
    int c = 0;
    for (unsigned n = 1; n <= 64; n++)
        if ((n & 7u) == 0) c++;
    printf("%d", c);
}
  1. A. 7
  2. B. 9
  3. C. 8
  4. D. 16

Correct answer: C. 8

The numbers are the multiples of 8 from 8 to 64, which is eight values.

More C Programming questions

Exams that ask this topic