Monday, January 17, 2011

Differentiate between constants and variable

Constants

variables

characteristics

Value is not changeable during the course of the program

Value can be changed anytime during the course of the program

usage

Use constant when you want to declare something that won’t change midway in your program execution.

Use variable to store data that may or will change during the running of the program.


Constant

- constants retain their value during the program execution
- example:

const PI=3.142
const GRAVITY=9.8
const WAGE=5.5

Variable

- variables can change their value during program execution
-example:

Dim Name as String
Dim Score as Integer
Dim Mark as Integer

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.