Home
/
Questions
/
What are variables and it what way is it different from constants?
Explanatory Question
What are variables and it what way is it different from constants?
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.
Variables and constants may at first look similar in a sense that both are identifiers made up of one character or more characters (letters, numbers and a few allowable symbols). Both will also hold a particular value. Values held by a variable can be altered throughout the program, and can be used in most operations and computations. Constants are given values at one time only, placed at the beginning of a program. This value is not altered in the program. For example, you can assigned a constant named PI and give it a value 3.1415 . You can then use it as PI in the program, instead of having to write 3.1415 each time you need it.