Begin Programming Logo
Home | KPL | Object Pascal | General Programming | Code Database | About Us
   
Constants
   
   

A constant can be thought of as the opposite of a variable. If a certain numerical value is used very often in a program it can be very tedious to change that value. One would have to look through the entire code and change it in each place.

That is where a constant comes in. Constants have a set value that is represented by a name (like a permanent variable). Each time you need to use the value you write the constants name. If the constant needs to be changed then all that is required is to change it in one place in the code; the constant declaration.


Example

Constant Tax = 10
NetPayment = GrossPayment - (GrossPayment*Tax)/100

   

Valid XHTML 1.0 Transitional Valid CSS!