AP CSP Day 53: Data Storage

Big Idea 3: Algorithms & Programming
Cycle 2 • Day 53 Practice • Hard Difficulty
Focus: Variables & Assignment

Practice Question

What is displayed after the following code runs?

a ← 1
b ← 2
c ← 3
a ← b + c
b ← a + c
c ← a + b
DISPLAY(c)
Why This Answer?

Trace each assignment using current values: a = b+c = 2+3 = 5. Then b = a+c = 5+3 = 8 (using updated a). Then c = a+b = 5+8 = 13 (using updated a and b). DISPLAY shows 13.

Why Not the Others?

A) 6 uses original values (1+2+3). Students who don't update variables get this wrong answer. C) 8 is the value of b, not c. D) 16 results from arithmetic errors in the trace.

Common Mistake
Watch Out!

Students use the original values (a=1, b=2, c=3) throughout all three computations instead of using the updated value of each variable as soon as it changes.

AP Exam Tip

In multi-step assignment problems, update your variable table immediately after each assignment. The next line must use the new values, not the originals.

Keep Practicing!

Consistent daily practice is the key to AP CSP success.

AP CSP Resources Get 1-on-1 Help
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.