Why is using named constants a good programming practice?

What will be an ideal response?


Using named constants is a good programming practice because it is less prone to the introduction of bugs into the source code. A retail program that calculates customer purchases needs to include sales tax on the amount of purchase. The sales tax percentage seldom changes, therefore using a named constant whose value is set once reduces the risk of the programmer mistyping the percentage, which would in turn introduce a logic error, the hardest error to track.

Computer Science & Information Technology

You might also like to view...

Answer the following statements true (T) or false (F)

1. When using the strcat function, you must be careful not to overflow the bounds of the array allocated for the target string. 2. The C++ compiler performs strict array bounds checking whenever an array of characters is being accessed. 3. The string class append member function str.append(s)tacks a string s to the end of str. 4. It is possible to implement a string class by using a dynamically allocated array of characters. 5. The following statement declares a string object and initializes it to "Once upon a time".

Computer Science & Information Technology

A module consists of ________, which are units of computer code that perform some type of action

A) procedures B) activities C) controls D) macros

Computer Science & Information Technology

Las pestañas de la Cinta organizan los comandos en tareas relacionadas. Los comandos de cada pestaña se organizan en ____.

A. categorías B. conjuntos C. menús D. grupos

Computer Science & Information Technology

If you are having a problem changing the permissions of a folder that was created by another user, what can you do to help solve the problem?

What will be an ideal response?

Computer Science & Information Technology