C Programming - Memory Allocation - Discussion

Discussion Forum : Memory Allocation - Find Output of Program (Q.No. 5)
5.
Assume integer is 2 bytes wide. How many bytes will be allocated for the following code?
#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4

int main()
{
    int (*p)[MAXCOL];
    p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p));
    return 0;
}
56 bytes
128 bytes
24 bytes
12 bytes
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
21 comments Page 3 of 3.

Viraj said:   1 decade ago
p is pointer to integer array of size 4

no of rows= 3
no of cols= 4
size of int=2

3*4*2=24


Post your comments here:

Your comments will be displayed after verification.