ProgrammingHard
On an n x n grid with n = 4, how many cells lie on at least one of the two main diagonals?
- A. 6
- B. 8
- C. 7
- D. 16
Correct answer: B. 8
The diagonals have 4 cells each and share none when n is even, so 4 + 4 = 8 cells.
More C Programming questions
- int a[2][2] = {1, 2, 3, 4}; What is a[1][0]?
- int a[2][3]; What is sizeof(a[1]) on a platform with 4-byte int?
- How many trailing zero bits does 96 have? (96 is 1100000 in binary.)
- What is the index of the highest set bit of 1000 (so 2^index is the largest power of two that is at most 1000)?
- uint16t x = 0x0F00; uint16t y = x & (uint16t)(0u - x); What is y?
- int a[] = {2, 4, 6, 8}; int p = a + 3, q = a; What does printf("%td", p - q) print?