Question bank › GCSE Computer Science › Programming fundamentals

Sub programs and random numbers

Answer on paper first, then reveal the mark scheme one mark at a time.

1Grade 6–75 marks

Look at the subprogram below.

function calc(a, b)
    if a > b then
        return a - b
    else
        return a * b
    endif
endfunction

(a) State the output of: (i) print(calc(9, 4)) [1] (ii) print(calc(3, 5)) [1]

(b) Identify one parameter in the subprogram. [1]

(c) Give one difference between a function and a procedure. [1]

(d) Give one benefit of using local variables in subprograms. [1]

Still losing marks on this topic?

Book a free introductory session and we'll find exactly which step is costing you.

Book a free intro