...
/Quiz Yourself on Heap and Dynamic Memory Allocations
Quiz Yourself on Heap and Dynamic Memory Allocations
Test your understanding of the material presented in this chapter.
We'll cover the following...
Heap and dynamic memory allocations
1
What is the output of the following code? Assume the allocation doesn’t fail.
int* arr = malloc(sizeof(int) * 5);
if(arr == NULL)
{
return;
}
printf("%d\n", arr[3]);
A)
The memory block is uninitialized, and the code prints garbage values.
B)
The memory block is initialized by default with 0
. The code prints 0
.
C)
The code will crash because arr[3]
is not a valid memory location.
D)
The code doesn’t compile.
Question 1 of 90 attempted
Access this course and 1400+ top-rated courses and projects.