ProgrammingHardGATE CS · TCS NQT
Assume int is 4 bytes. What is printed?
Assume int is 4 bytes. What is printed?
#include <stdio.h>
int main(void) {
int a[4][5];
printf("%ld", (long)((char *)&a[3][0] - (char *)&a[0][0]));
}- A. 15
- B. 48
- C. 60
- D. 12
Correct answer: C. 60
Rows are five ints, so a[3][0] is 3 * 5 * 4 = 60 bytes after a[0][0]. Measuring in elements gives 15 instead.
More C Programming questions
- What is printed? c #include <stdio.h> int total = 0, c1 = 0; void hanoi(int n, char a, char b, char c) { if (n == 0) return; hanoi(n - 1…
- What is printed? c #include <stdio.h> int bit[9] = {0}; void add(int i, int v) { for (; i <= 8; i += i & -i) bit[i] += v; } int query(int…
- Assume int is 32 bits. What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t b = 0xF3; int e = (int)(b ^…
- What is printed? c #include <stdint.h> #include <stdio.h> int tz(uint32t x) { int n = 0; while (!(x & 1u)) { x >>= 1; n++; } return n; }…
- Assume int is 32 bits with limits INTMIN = -2147483648 and INTMAX = 2147483647. What is printed? c #include <limits.h> #include <stdio.h>…
- int n = 8, c = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j = 2) c++; printf("%d", c); What is printed?