nerdexam
CompTIA

FC0-U71 · Question #90

A user is writing code to calculate the amount of pay for each worker at a company. The pay rate is the same for all workers. The code will use the formula amount_of_pay = nunber_of_hours * pay_rate W

The correct answer is C. Constant. A constant is a named value that does not change during program execution. Since the pay rate is the same for all workers and does not vary, it should be declared as a constant rather than a variable. This prevents accidental modification, improves code readability, and signals t

Software Development Concepts

Question

A user is writing code to calculate the amount of pay for each worker at a company. The pay rate is the same for all workers. The code will use the formula amount_of_pay = nunber_of_hours * pay_rate Which of the following should be used in the code to represent pay_rate?

Options

  • AObject
  • BFunction
  • CConstant
  • DArray

How the community answered

(53 responses)
  • A
    2% (1)
  • B
    2% (1)
  • C
    91% (48)
  • D
    6% (3)

Explanation

A constant is a named value that does not change during program execution. Since the pay rate is the same for all workers and does not vary, it should be declared as a constant rather than a variable. This prevents accidental modification, improves code readability, and signals to other developers that the value is intentionally fixed. An object or array would be overly complex for a single fixed value, and a function is used to perform actions, not store a static value.

Topics

#Constants#Programming Fundamentals#Data Representation

Community Discussion

No community discussion yet for this question.

Full FC0-U71 Practice