Prelim Exam Blueprint & Study Plan
This module preps you for exams on everything in the currently published Unit 1: Arrays. Coverage will expand as new units are published.
How a CP2 Prelim on Arrays Is Usually Structured
Different professors shuffle the weights, but almost every CP2 prelim on arrays is built from the same four parts:
| Part | Format | Typical Weight | What It Really Tests |
|---|---|---|---|
| I | Multiple choice / identification | 25–35% | Rules: declaration syntax, indexing, initialization behavior |
| II | Output tracing | 25–35% | Can you run a loop over an array in your head, line by line |
| III | Debugging / spot-the-error | 10–20% | Off-by-one loops, missing & in scanf(), illegal array assignment |
| IV | Fill-in-the-blank / write-the-code | 20–30% | Producing the standard array idioms from memory |
Tracing plus write-the-code is usually more than half the exam. You cannot pass by memorizing definitions alone — you have to practice running code on paper.
Your Exact Memorize List
If you can do all ten of these cold, you are ready:
- Declaration syntax —
data_type array_name[size];for 1D anddata_type array_name[rows][columns];for 2D. - The three initialization rules — more values than elements is a compile error; fewer values means the rest become zero; if you initialize everything you may omit the size.
- Indexing starts at zero — for
int num[20], valid positions arenum[0]throughnum[19]. There is nonum[20]. - The address formula — element address = base address + (size of one element × index). Expect one arithmetic item on this.
- The loop-over-array idiom —
for (i = 0; i < n; i++), andscanf("%d", &a[i]);with the address-of operator. - No whole-array assignment —
second = first;is illegal; copy element by element with a loop. - Strings end with
'\0'— a string literal ofnletters needsn + 1array slots. - 2D traversal — nested loops, rows outside, columns inside; a flat initializer list fills row by row (the last subscript increases fastest).
- Swapping needs a temp variable — three assignments:
temp = a; a = b; b = temp;. - The compare-and-swap sorting logic from Sample Program 1 — if the left neighbor is bigger, swap the pair.
Top Mistakes That Cost Points
- Writing
a[size]as if it were the last element — the last element isa[size - 1]. - Using
<=where<belongs in a loop condition, reading one slot past the end. - Forgetting
&inscanf("%d", &a[i]);. - Filling a 2D initializer column-first instead of row-first when tracing.
- Assuming a declared-but-uninitialized array holds zeros (only partially initialized arrays zero-fill the remainder).
- "Swapping" with two assignments and no temp — one value gets destroyed.
Realistic 7-Day Study Plan
Each day is keyed to section titles in Unit 1. Around 45–60 minutes a day is enough.
| Day | Study These Sections | What To Actually Do |
|---|---|---|
| 1 | "What is an Array and Why Do We Need One?" + "Characteristics of an Array" | Read both, then write the three defining properties from memory. Explain index notation out loud in one sentence. |
| 2 | "Declaring an Array in C" + "How C Finds an Element in Memory" | Write 10 declarations of your own (mix int, float, char, double). Compute 5 element addresses by hand with the formula. |
| 3 | "Storing Values in an Array" | Memorize the three ways to store values and the three initialization rules. Write the array-copy loop from memory twice. |
| 4 | "Character Arrays and Strings" + "Multidimensional Arrays" | Draw the memory picture of a string including '\0'. Fill a 3×3 table from a flat initializer list by hand. |
| 5 | "Sample Program 1 — Sorting an Array" + "Sample Program 2 — Counting Positives and Negatives" | Trace both programs on paper with your own input values before checking the expected output. |
| 6 | "Sample Program 3 — Adding Two Matrices" + "Practice Exercises" | Do all three trace exercises (Programs A, B, C) with a timer — 5 minutes each. |
| 7 | The Free Practice Set below | Simulate exam conditions: 30 minutes, no notes. Review every miss against the Unit 1 section it came from. |
Free Practice Set — 15 Items with Answer Key
Fifteen genuine exam-style items on one-dimensional arrays. Do all fifteen before looking at the key — treat it like the real thing: 30 minutes, no notes.
Part I — Multiple Choice (Items 1–5)
1. Given int num[20];, which positions are valid?
- A.
num[1]throughnum[20] - B.
num[0]throughnum[19] - C.
num[0]throughnum[20] - D.
num[1]throughnum[19]
2. Which declaration correctly creates a 20-element integer array?
- A.
int scores(20); - B.
array int scores[20]; - C.
int scores[20]; - D.
int[20] scores;
3. After int c[15] = {3, 7, 4, 6, 1};, what is the value of c[9]?
- A. 0
- B. 1
- C. Garbage (unpredictable)
- D. Compile error
4. How many elements does int b[] = {11, 21, 75, 24, 5}; have?
- A. Unknown until runtime
- B. 4
- C. 5
- D. Compile error — size is required
5. An integer array starts at memory address 5,000 and each integer occupies 4 bytes. What is the address of the element at index 6?
- A. 5,006
- B. 5,020
- C. 5,024
- D. 5,028
Part II — Output Tracing (Items 6–9)
Write exactly what each fragment prints.
6.
int a[6] = {4, 9, 2, 7, 6, 3};
int i, s = 0;
for (i = 0; i < 6; i++)
if (a[i] % 2 == 0)
s += a[i];
printf("%d", s);
7.
int c[5] = {2, 4, 6, 8, 10};
int a, b = 0;
for (a = 0; a < 5; a++)
if ((a % 2) == 0)
b += c[a];
printf("%d", b);
8.
int a[5] = {12, 5, 19, 8, 15};
int i, big = a[0];
for (i = 1; i < 5; i++)
if (a[i] > big)
big = a[i];
printf("%d", big);
9.
int a[4] = {3, 1, 4, 1};
int i;
for (i = 3; i >= 0; i--)
printf("%d", a[i]);
Part III — Spot the Error (Items 10–12)
10. int a[10]; is declared. What is wrong here, and what is the fix?
for (i = 0; i <= 10; i++)
scanf("%d", &a[i]);
11. What is wrong here, and what is the fix?
for (i = 0; i < 10; i++)
scanf("%d", a[i]);
12. Is this declaration legal? Why or why not?
int a[5] = {1, 2, 3, 4, 5, 6};
Part IV — Fill in the Blank (Items 13–15)
13. char city[] = "CEBU"; — how many elements does city have?
14. Complete the loop so that every element of first is copied into second (both are 25-element int arrays):
for (i = 0; i < 25; i++)
____;
15. Complete the statement so the program counts the negative values in a (size n):
for (i = 0; i < n; i++)
if (____)
count_neg++;
Answer Key
| # | Answer | One-Line Why |
|---|---|---|
| 1 | B | Indexing starts at 0, so 20 elements occupy positions 0 through 19. |
| 2 | C | data_type array_name[size]; — square brackets after the name. |
| 3 | A | Only 5 of 15 elements are initialized; the remaining elements (indices 5–14) are automatically set to zero. |
| 4 | C | When all elements are initialized, the compiler counts them — 5 values means size 5. |
| 5 | C | 5,000 + (4 × 6) = 5,024, straight from the address formula. |
| 6 | 12 | The even values are 4, 2, and 6; 4 + 2 + 6 = 12. |
| 7 | 18 | The condition tests the index, not the value: indices 0, 2, 4 give 2 + 6 + 10 = 18. |
| 8 | 19 | Classic find-the-largest: 19 beats 12; 5, 8, 15 never do. |
| 9 | 1413 | Printed in reverse index order: a[3], a[2], a[1], a[0] = 1, 4, 1, 3. |
| 10 | Change <= to < | i <= 10 reads into a[10], one slot past the last element a[9]. |
| 11 | Add &: &a[i] | scanf() needs the address-of operator, just as with ordinary variables. |
| 12 | Illegal — compile error | Six initializers for five elements; you cannot supply more values than there are elements. |
| 13 | 5 | Four letters plus the automatic null terminator '\0'. |
| 14 | second[i] = first[i] | Arrays cannot be assigned whole; copy element by element. |
| 15 | a[i] < 0 | Test each element against zero, exactly as in Sample Program 2. |
Scored 12 or better? You are on track. Below that, go back to the Day-by-day plan above and re-trace the sample programs. The four full mock exams below — 100 fresh items with complete answer keys and worked traces — come with the subject unlock.
Prelim Mock Exam A — 25 Items
ProReviewer — locked
Drills, code labs, and full solutions.
Prelim Mock Exam B — 25 Items
ProReviewer — locked
Drills, code labs, and full solutions.
Prelim Mock Exams — Answer Key with Explanations
ProReviewer — locked
Drills, code labs, and full solutions.
Common Array Traps & How to Avoid Them
ProReviewer — locked
Drills, code labs, and full solutions.
Final Exam Blueprint & Rapid Review Sheet
ProReviewer — locked
Drills, code labs, and full solutions.
Final Mock Exam A — 25 Items
ProReviewer — locked
Drills, code labs, and full solutions.
Final Mock Exam B — 25 Items
ProReviewer — locked
Drills, code labs, and full solutions.
Final Mock Exams — Answer Key with Explanations
ProReviewer — locked
Drills, code labs, and full solutions.