Three problems on PROCEDURE and RETURN — Activities 2.1 to 2.3, in AP exam notation. Two translate C# into exam notation, and one traces. The trace is the one that catches people.
Work these on paper. There is no computer on exam day.
The reference sheet's procedures. Arithmetic, assignment with ←, and IF work the way they did in earlier pseudocode challenges.
PROCEDURE procName(parameter1, parameter2){ <block of statements>}PROCEDURE procName(parameter1, parameter2){ <block of statements> RETURN(expression)}procName(arg1, arg2)result ← procName(arg1, arg2)DISPLAY(expression)Four rules that catch people:
RETURN takes parentheses: RETURN(width * height). C#'s return does not, which is why this one is easy to get backward.int, no void, no string — in the header or anywhere else.←, and there are no semicolons.$"..." on the reference sheet. DISPLAY shows one value and puts a space after it.Rewrite this method and the two lines that use it in exam notation.
int AreaOf(int width, int height){ return width * height;}int a = AreaOf(5, 3);Console.WriteLine(a);Then say what your version displays.
What does this display?
PROCEDURE twice(n){ RETURN(n * 2)}
x ← twice(6)DISPLAY(x)DISPLAY(twice(x))Careful: the last line calls the procedure again. It does not reuse the first result — work out what its argument is first.
Rewrite this in exam notation.
Label("Avery", 88);
void Label(string name, int score){ Console.WriteLine($"{name}: {score}");}Then answer this: one line does not translate directly. Say which one, what you wrote instead, and whether your version displays exactly the same thing.
This is graded on completion, not accuracy. Show your working for the trace — a wrong answer with visible reasoning is worth more to both of us than a right one with none.