LearnFrenzy
Sign in Take a free test

Memory Allocation · Exercise 1 of 4

Memory Allocation Memory Allocation MCQ

  • 12 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twelve multiple-choice questions on malloc, calloc, realloc and free, stack vs heap, memmove, alignment and C23. Pick an option to check your answer instantly.

Question 11 Easy

A function returns a pointer it got from malloc(). Is the memory still valid in the caller?

A No, it is freed when the function returns
B Yes – heap memory lives until free() is called
C Only if the pointer is static
D Only until the next malloc()
Question page & discussion
Question 12 Hard

What does aligned_alloc(64, 256) return?

A A 256-byte block whose address is a multiple of 64, freed with free()
B 64 blocks of 256 bytes
C A block on the stack
D A 64-byte block aligned to 256
Question page & discussion
Up next · Exercise 2Predict the Output12 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links