logo

Question detail

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, check the answer, then read the explanation to understand the curriculum point.

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.

Model answer

What a good answer should say

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

Explanation

Why this works

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.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.