Search Header Logo

Dynamic Memory Management MCQ Quiz

Authored by Nancy P

Computers

University

Used 4+ times

Dynamic Memory Management MCQ Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which call correctly allocates space for 50 integers?

int *p = malloc(50);

int *p = malloc(50 * sizeof(int));

int *p = calloc(sizeof(int), 50);

Both B and C

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Compared to malloc, calloc additionally:

Aligns memory

Initializes memory to zero

Allocates on the stack

Guarantees contiguous physical pages

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a typical C program, how do the heap and stack grow in memory?

Both grow upwards

Both grow downwards

Stack grows downward, heap grows upward

Stack grows upward, heap grows downward

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a key difference between stack and heap memory allocation?

Stack is slower but dynamic; heap is faster and fixed

Stack is manual; heap is automatic

Stack is automatically managed; heap requires manual management

Heap variables are cleared on function exit

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which statement creates a pointer to a structure and allocates memory dynamically?

struct item *p = malloc(sizeof(struct item));

struct item p = malloc(sizeof(item));

item *p = new item;

struct item p; *p = malloc(sizeof(p));

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which is valid?

free(&x); where int x;

free(p); where p points to malloced memory

free(p+1); where p points to malloced memory

free((void*)0x1234);

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

realloc(p, 0) does:

Always equivalent to free(p) and returns NULL

Keeps memory unchanged

Undefined behavior

Returns pointer to a zero-sized usable block

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers