Recall & Review
beginner
What is an array in C?
An array in C is a collection of elements of the same type stored in contiguous memory locations. It allows storing multiple values under a single name.
Click to reveal answer
beginner
How do you declare an integer array of size 5 in C?
You declare it as:
int arr[5]; This creates space for 5 integers in memory.Click to reveal answer
beginner
What is the difference between declaration and initialization of an array?
Declaration creates the array with a specified size but does not assign values. Initialization assigns values to the array elements at the time of declaration or later.
Click to reveal answer
beginner
How to initialize an array with values at the time of declaration?
Example:
int arr[3] = {10, 20, 30}; This creates an array of size 3 with elements 10, 20, and 30.Click to reveal answer
intermediate
What happens if you initialize fewer elements than the declared size?
The remaining elements are automatically set to zero. For example,
int arr[5] = {1, 2}; sets arr[0]=1, arr[1]=2, and arr[2], arr[3], arr[4] = 0.Click to reveal answer
How do you declare an array of 10 floats in C?
✗ Incorrect
Option C correctly declares an array of 10 floats.
What is the index of the first element in a C array?
✗ Incorrect
C arrays start indexing from 0.
What will be the value of arr[3] after this declaration? <br>
int arr[5] = {1, 2, 3};✗ Incorrect
Elements not initialized explicitly are set to 0.
Which of the following is a valid initialization of an array in C?
✗ Incorrect
Option D correctly initializes an array with inferred size.
What is the size of the array declared as
int arr[4];?✗ Incorrect
The array has 4 elements as declared.
Explain how to declare and initialize an integer array of size 5 with values 1 to 5 in C.
Use int arr[5] = {...}; syntax.
You got /3 concepts.
Describe what happens when you declare an array but do not initialize it in C.
Think about default values in local arrays.
You got /3 concepts.
