ProgrammingHardTCS NQT · Infosys
How many integers from 1 to 100 are divisible by 3 or by 5?
- A. 47
- B. 46
- C. 33
- D. 53
Correct answer: A. 47
There are 33 multiples of 3 and 20 multiples of 5, and 6 multiples of 15 counted twice. So 33 + 20 - 6 = 47.
More C Programming questions
- How many two-digit decimal numbers have digits summing to 9?
- The sorted array is {1, 3, 5, 7, 7, 9}. What is the index of the first element greater than 7?
- int n = 0; reading the expression as C does: What is the value of ~5 + 1?
- int n = 0; while (n++ < 3) ; What is n after the loop?
- unsigned char x = 100; x += 200; What is x?
- int x = 12; x &= x - 1; What is x?