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);
}- A. 17
- B. 25
- C. 8
- 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
- What is printed by this memoised recursion? The static memo table starts with every entry zero, and calls counts each call to f. c…
- What is printed? c #include <stdio.h> int main(void) { int arr[2 3 + 1]; printf("%zu", sizeof arr / sizeof arr[0]); }
- How many paths go from the top-left to the bottom-right of a 3 by 3 grid of points, moving right or down, without passing through the…
- What is printed? c #include <stdio.h> int main(void) { int a = 2147483647; printf("%u", (unsigned)a + 1u); }
- How many integers from 1 to 64 have their low three bits all clear? Compute with this program. c #include <stdio.h> int main(void) { int c…
- How many times does the letter g occur in "programming"? The program counts it with a pointer walk. c #include <stdio.h> int main(void) {…