Recall & Review
beginner
What is array initialization in C?
Array initialization is the process of assigning values to an array at the time of its creation.
Click to reveal answer
beginner
How do you initialize an integer array of size 5 with values 1, 2, 3, 4, 5 in C?
int arr[5] = {1, 2, 3, 4, 5};
Click to reveal answer
intermediate
What happens if you initialize an array with fewer values than its size?
The remaining elements are automatically set to zero.
Click to reveal answer
intermediate
Can you initialize an array without specifying its size? How?
Yes, by letting the compiler count the values: int arr[] = {1, 2, 3}; The size is 3 automatically.
Click to reveal answer
intermediate
What is the difference between partial and full array initialization?
Full initialization assigns values to all elements. Partial initialization assigns values to some elements; the rest are zeroed.
Click to reveal answer
How do you initialize an array of 4 integers with all zeros in C?
✗ Incorrect
Using {0} sets the first element to zero and the rest are automatically zeroed.
What is the size of the array in: int arr[] = {5, 10, 15}; ?
✗ Incorrect
The compiler counts the values and sets the size to 3.
If you write int arr[5] = {1, 2}; what are the values of arr[2], arr[3], and arr[4]?
✗ Incorrect
Elements not initialized explicitly are set to zero.
Which of these is NOT a valid way to initialize an array in C?
✗ Incorrect
You cannot initialize more elements than the array size.
What is the value of arr[0] after this initialization? int arr[3] = {};
✗ Incorrect
Empty braces initialize all elements to zero.
Explain how to initialize an array in C and what happens if you provide fewer values than the array size.
Think about how you fill a row of boxes with some candies and leave the rest empty.
You got /3 concepts.
Describe how the compiler determines the size of an array when you don't specify it explicitly during initialization.
Imagine counting how many apples you put in a basket to know its size.
You got /3 concepts.