ProgrammingModerateTCS NQT · Infosys
How many integers from 1 to 30 are multiples of 8?
- A. 4
- B. 3
- C. 2
- D. 30
Correct answer: B. 3
The multiples are 8, 16 and 24, so the count is 3. Testing n & 7 == 0 is the bit form of the same check.
More C Programming questions
- A circular buffer of size n = 5 steps back from index 0 with (idx + n - 1) % n. What index results?
- A qsort comparator orders the elements in descending order. After sorting {5, 9, 2}, what is the first element?
- uint32t x = 491u; What is (x >> 3) & 7? (491 is 0x1EB.)
- uint32t r = 2147483648u % 1000u; What is r?
- uint32t p = 65536u 65537u; What is p?
- int a[] = {1, 2, 3, 4, 5}; int p = a; p += 3; printf("%d", p--); What is printed?