logo

AQA A-Level Computer Science practice

A programmer needs a value that is used only while one function performs a calculation. Which choice best matches the contrast between local and global variables?

Try the question first, then check the answer and practise the same topic again.

At a glance

MCQ

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

A programmer needs a value that is used only while one function performs a calculation. Which choice best matches the contrast between local and global variables?.

  1. A.Use a local variable because its access is restricted to the relevant part of the program.
  2. B.Use a global variable because every variable must be accessible everywhere.
  3. C.Use a global variable because local variables cannot store calculated values.
  4. D.Use a local variable because local variables are always stored as text.

Answer and explanation

Concise answer

Use a local variable because its access is restricted to the relevant part of the program.

Why this is correct

When a value is needed only in one function, a local variable matches that limited use. The contrast is based on where the variable can be accessed, not on the type of data it stores.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions