Back to Challenge Set 1

Pseudocode Challenge: Arithmetic

Difficulty  

divider

Objective

Rewrite short C# programs in the notation the AP exam uses. No computer needed — this one works on paper, and doing it on paper is closer to the real thing.

You will never write this notation in a real program. You only need to read it fluently, because that is what the multiple-choice section is made of. Translating in this direction is how reading gets easy.

Skills to Practice

  • Reading and writing assignment as an arrow
  • Splitting an interpolated string into separate DISPLAY statements
  • Recognizing MOD as the same operation as %
  • Remembering that exam-notation / never truncates, even when both operands are whole numbers

What You Are Allowed to Use

Everything from the exam reference sheet that we have covered so far. Nothing else appears in these problems.

Assignment
a ← expression
Display
DISPLAY(expression)
Arithmetic
a + b a - b
a * b a / b
a MOD b
Random
RANDOM(a, b)

Three rules that catch people:

  • Assignment is ←, never =. If you are writing by hand, draw the arrow.
  • DISPLAY takes one value. Interpolated text and a value together means two statements.
  • There is no string interpolation and no explicit type. A variable comes into existence the first time you assign to it.

Worked Example

C#
int total = 12 + 8;
Console.WriteLine(total);
Exam Notation
total ← 12 + 8
DISPLAY(total)

Two lines in, two lines out. Notice what disappeared: int and the semicolons.


Translate These

Write the exam-notation version of each program. Line for line where you can.


1

Problem 1
int itemsSold = 15;
Console.WriteLine(itemsSold);

2

Careful with the last line. An interpolated string that mixes label text with a value does not stay one statement — exam notation has no $"...".

Problem 2
int cookiesBaked = 53;
int boxSize = 8;
int extra = cookiesBaked % boxSize;
Console.WriteLine($"Left over: {extra}");

3

Keep the parentheses. They mean the same thing in both notations.

Problem 3
int a = 9;
int b = 4;
int c = (a + b) * 2;
Console.WriteLine($"Result: {c}");

4 — The Other Direction

This one is already in exam notation. Write down exactly what it displays, in order.

Problem 4
x ← 17
y ← 5
DISPLAY(x / y)
DISPLAY(x MOD y)

Both answers are different numbers, and neither one is a whole-number division. Work them out by hand before checking — and remember Activity 1.6's lesson about / runs backward here. C# truncates int / int unless you force real division; the exam's / never truncates at all, on any two numbers.


Submit

  • Your translations of problems 1, 2, and 3
  • The two values displayed by problem 4
  • One sentence: which part of the translation felt least natural, and why?

Handwritten and photographed is fine, and is the closest thing to exam conditions.

Commence Challenge