C Programming - Memory Allocation

1.
Point out the correct statement will let you access the elements of the array using 'p' in the following program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int i, j;
    int(*p)[3];
    p = (int(*)[3])malloc(3*sizeof(*p));
    return 0;
}
for(i=0; i<3; i++)
{
    for(j=0; j<3; j++)
        printf("%d", p[i+j]);
}
for(i=0; i<3; i++)
    printf("%d", p[i]);
for(i=0; i<3; i++)
{
    for(j=0; j<3; j++)
        printf("%d", p[i][j]);
}
for(j=0; j<3; j++)
    printf("%d", p[i][j]);
Answer: Option
Explanation:
No answer description is available. Let's discuss.

2.
Which of the following statement is correct prototype of the malloc() function in c ?
int* malloc(int);
char* malloc(char);
unsigned int* malloc(unsigned int);
void* malloc(size_t);
Answer: Option
Explanation:
No answer description is available. Let's discuss.

3.
Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    struct ex
    {
        int i;
        float j;
        char *s
    };
    struct ex *p;
    p = (struct ex *)malloc(sizeof(struct ex));
    p->s = (char*)malloc(20);
    return 0;
}
free(p); , free(p->s);
free(p->s); , free(p);
free(p->s);
free(p);
Answer: Option
Explanation:
No answer description is available. Let's discuss.

4.
Point out the correct statement which correctly allocates memory dynamically for 2D array following program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int *p, i, j;
    /* Add statement here */
    for(i=0; i<3; i++)
    {
        for(j=0; j<4; j++)
        {
            p[i*4+j] = i;
            printf("%d", p[i*4+j]);
        }
    }
    return 0;
}
p = (int*) malloc(3, 4);
p = (int*) malloc(3*sizeof(int));
p = malloc(3*4*sizeof(int));
p = (int*) malloc(3*4*sizeof(int));
Answer: Option
Explanation:
No answer description is available. Let's discuss.