What is the difference between Variables and Constants? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between Variables and Constants?

3rd Nov 2016, 9:15 AM
kenil
kenil - avatar
3 Answers
+ 11
Variables can be constant or not. If you are declaring a constant variable, this means you can't change its value after declaring it.
3rd Nov 2016, 9:31 AM
Remmae
Remmae - avatar
+ 1
Variables and Constants are "Variables", the difference between a Variable and a Constant is that once you declare it a Constant it won't be able to change it's value by any othere method you will write or by any other code. It's usually used for mathematical constants like "pi" or "e" or even in most (of course not all) games the value for gravity.
3rd Nov 2016, 10:36 AM
Waldemar Alexander Sulej
Waldemar Alexander Sulej - avatar
+ 1
A variable is a dynamic entity(it can be changed by need). A constant is a static entity(it can not be changed).
12th Nov 2016, 6:21 AM
Manikanta Pilla
Manikanta Pilla - avatar