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 you to store multiple values under a single name and access them using an index.
Click to reveal answer
beginner
How do you access the third element of an array named
arr?You access it using
arr[2] because array indexing starts at 0 in C.Click to reveal answer
intermediate
How do you find the length of a statically declared array in C?
Use
sizeof(arr) / sizeof(arr[0]) to get the number of elements in the array.Click to reveal answer
intermediate
How can you copy elements from one array to another in C?
You can copy elements using a loop to assign each element individually, for example:<br>
for(int i = 0; i < n; i++) { dest[i] = src[i]; }Click to reveal answer
advanced
What is the result of accessing an array out of its bounds in C?
Accessing out of bounds leads to undefined behavior. It can cause crashes or incorrect data because C does not check array bounds.
Click to reveal answer
What is the index of the first element in a C array?
✗ Incorrect
In C, array indexing always starts at 0.
Which of the following correctly declares an array of 5 integers?
✗ Incorrect
The correct syntax to declare an array of 5 integers is
int arr[5];.How do you get the number of elements in a statically declared array
arr?✗ Incorrect
In C, you calculate the number of elements by dividing the total size of the array by the size of one element.
What happens if you access
arr[10] when arr has only 5 elements?✗ Incorrect
Accessing beyond the array size causes undefined behavior in C.
Which loop is commonly used to iterate over all elements of an array?
✗ Incorrect
A for loop is typically used to iterate over arrays because it clearly controls the index.
Explain how to declare, initialize, and access elements of an array in C.
Think about how you store multiple values and get each one by its position.
You got /3 concepts.
Describe common operations you can perform on arrays in C and any risks involved.
Consider what you do with a list of items and what can go wrong if you go outside the list.
You got /4 concepts.