LearnFrenzy
Sign in Take a free test

Typedef · Predict the Output · Question 3

Array typedef used for a 2D grid – sizes Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

What is the output of the following C program on a 64-bit system?

main.c
#include <stdio.h>

typedef int Row[4];

int main(void) {
    Row grid[3];
    printf("%zu %zu %zu\n", sizeof(Row), sizeof grid, sizeof grid / sizeof grid[0]);
    return 0;
}
  • A 16 48 3 Correct
  • B 4 12 3
  • C 16 48 4
  • D 16 12 4
Correct Answer: Option A

A Row is 4 ints = 16 bytes. grid holds 3 Rows = 48 bytes, so it has 3 elements (rows).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links