ProgrammingHardTCS NQT · Wipro

How many numbers from 1 to 100 are divisible by 4 but not by 3? Compute with this program.

How many numbers from 1 to 100 are divisible by 4 but not by 3? Compute with this program.
#include <stdio.h>
int main(void) {
    int c = 0;
    for (int n = 1; n <= 100; n++)
        if (n % 4 == 0 && n % 3 != 0) c++;
    printf("%d", c);
}
  1. A. 17
  2. B. 25
  3. C. 8
  4. D. 33

Correct answer: A. 17

There are 25 multiples of 4 up to 100, and 8 of them (12, 24, ..., 96) are also multiples of 3, leaving 17.

More C Programming questions

Exams that ask this topic