Recall & Review
beginner
What does
array traversal mean in C programming?Array traversal means visiting each element of an array one by one, usually using a loop, to read or modify its values.
Click to reveal answer
beginner
Which loop is commonly used for array traversal in C?
The
for loop is commonly used because it allows easy control of the index from 0 to the array size minus one.Click to reveal answer
beginner
What is the starting index of an array in C?
The starting index of an array in C is 0, meaning the first element is accessed with index 0.
Click to reveal answer
beginner
Show a simple C code snippet to print all elements of an integer array named
arr of size n.for (int i = 0; i < n; i++) {
printf("%d\n", arr[i]);
}
Click to reveal answer
beginner
Why is it important to use the correct array size when traversing an array?
Using the correct size prevents accessing memory outside the array, which can cause errors or crashes.
Click to reveal answer
What is the first index used when traversing an array in C?
✗ Incorrect
Arrays in C start at index 0, so traversal begins at 0.
Which loop is best suited for traversing an array when the size is known?
✗ Incorrect
The for loop is ideal for known sizes because it controls the index easily.
What happens if you traverse beyond the array size in C?
✗ Incorrect
Accessing outside array bounds causes undefined behavior and can crash the program.
How do you access the third element of an array named
arr?✗ Incorrect
Since indexing starts at 0, the third element is at index 2.
Which of these is a correct way to traverse an array of size
n?✗ Incorrect
Looping from 0 to less than n covers all valid indices.
Explain how to traverse an array in C and why the starting index is important.
Think about how arrays are indexed and how loops help visit each element.
You got /3 concepts.
Describe what could happen if you try to access an array element outside its size during traversal.
Consider what happens when you read memory not allocated for the array.
You got /3 concepts.