Array created
Five contiguous cells, indexed from 0 to 4.
C programming · Lesson
Visualize an array as numbered cells and connect each index to the corresponding C expression v[i].
An array stores multiple values of the same type under one name. Indices start at 0: a five-element array has valid indices 0, 1, 2, 3 and 4.
v[0] · v[1] · v[2] · v[3] · v[4] → one cell per index
The flowchart keeps algorithm control visible; the Array Lab below makes cells, indices, comparisons, candidates and swaps visible.
Indices stay visible at all times. Sorting traces highlight comparisons, the current candidate, swaps and the region already sorted.
Five contiguous cells, indexed from 0 to 4.
Index 2 selects the third cell: its value is 2.
Run C executes only the example shown on the left, using stdin on the right. The coding challenge below has a separate editor and test button.
1#include <stdio.h>
2
3int main(void)
4{
5 int v[5] = {4, 7, 2, 9, 1};
6 printf("%d\n", v[2]);
7 return 0;
8}
Read five integers into an array; print first and last.
This is a different program from lab 1. Complete the starter code: Check all test cases compiles this editor and tests every input, including boundary cases.
In the array {4, 7, 2, 9, 1}, what value is stored in v[2]?
Challenge 1 / 5 · Understanding
Progress: 0 / 5 · correct: 0
ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.
Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.