answersLogoWhite

0


Best Answer

A constant is simply a variable (or object) that does not change value from the user's point of view. By notifying the language compiler that a value is not meant to be changed, the compiler will allocate that value to static memory, regardless of where that constant is physically declared in your source code (whether at global scope, file scope, class scope, function scope or local scope). Moreover, if you have more than one constant of the same type and value, the compiler will allocate only one instance of that value, thus saving memory.

The disadvantage to constants is largely a result of misuse. For instance, programmers are notorious for wanting to keep all constants in the same place (such as a constants.h file in C or a static class in C++). However, this is rarely a good idea given that any decent compiler will put all constants in the same place anyway; in static memory. Declaring constants as and when they are actually required makes code much easier to read and maintain because the value is right there in the code itself; you don't have to go looking it up.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is an advantage and disadvantage of a constant in programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the disadvantage and advantage of pascal programming?

You would be using an obsolete development environment and a pretty old dialect.


What are the advantage and disadvantage of fidelio?

What are the advantage and disadvantage of fidelio?"


What are the advantage and disadvantage of branch libraries?

what are the advantage and disadvantage branch libraries


What are the advantage and disadvantage of sampling techniques?

what are the advantage of and disadvantage of sampling method


What is the advantage and disadvantage of market free?

advantage is its fpree. Disadvantage is that its not fpree.


What is the difference between a disadvantage and an advantage?

Advantage and disadvantage are complete opposites. An advantage is something which is beneficial to an individual. A disadvantage would be not to ones benefit.


What is the advantage and disadvantage of flashing bios?

i want know to what is advantage and Disadvantage of BIOS


Advantage or disadvantage of overhung latrine?

smells bad - disadvantage cheap - advantage


What are the advantage and disadvantage of typing?

what are the advantage and disadvantage of typing what is online typing tutorails


Advantages and disadvantages of radio and television?

An advantage of radio would include the fact that information can be spread across a wide area relatively cheaply. A disadvantage of radio might be that there is no face to face contact via radio. An advantage of television might include the fact that television programming can affect a large range of people. A disadvantage might include the cost of advertising or programming on television.


What is are advantage and disadvantage of sweating?

disadvantage: you stink


Advantage and disadvantage of gadget?

the advatage is youre and disadvantage is advantage the gadget is moaso advantage is mind in powering objects..