logo

Question detail

A program uses the same tax rate in several calculations. Which approach best applies the idea of a named constant?

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 program uses the same tax rate in several calculations. Which approach best applies the idea of a named constant?.

  1. A.Store the rate under a meaningful constant name and use that name in the calculations
  2. B.Use a different literal rate in each calculation
  3. C.Store the rate in a variable and deliberately change it before every calculation
  4. D.Replace the rate with a comment

Model answer

What a good answer should say

  • Store the rate under a meaningful constant name and use that name in the calculations

Explanation

Why this works

A named constant gives the shared value a meaningful identity and helps keep the value consistent wherever it is used.

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.