ProgrammingHardTCS NQT · Infosys
int m[3][4]; What is sizeof(m) / sizeof(m[0][0])?
- A. 3
- B. 12
- C. 4
- D. 16
Correct answer: B. 12
sizeof(m) is 12 times sizeof(int), so the ratio is the element count 12 for any size of int. The 3 and 4 are the row and column counts, not the total.
More C Programming questions
- int a[] = {1, 2}; int b[] = {3, 4}; int x = a, y = b; void swap(int p, int q) { int t = p; p = q; q = t; } After swap(&x, &y) runs, what…
- A recursive function is written as int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }. What is gcd(1071, 462)?
- Starting at n = 27, the loop while (n != 1) { n = (n % 2) ? 3 n + 1 : n / 2; steps++; } runs with int n. What is steps at the end?
- Using square-and-multiply on int values with a reduction modulo 1000 after each multiplication, what is 3^13 mod 1000?
- How many 6-bit masks have exactly two 1 bits and have bit 0 cleared?
- The binary-reflected Gray code of i is g(i) = i ^ (i >> 1). What is g(4)?