Could anyone give a couple of examples of when you would need to use a constant? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Could anyone give a couple of examples of when you would need to use a constant?

11th Jul 2016, 6:00 PM
Connar
Connar - avatar
2 Answers
+ 1
when you have a value that may need to be changed but not at runtime. Or a value that is repeated several times, such as pi in the example.
12th Jul 2016, 11:42 AM
Bernhard Eriksson
Bernhard Eriksson - avatar
- 1
Like intrest value in Bank system , its constant value according to account type and it is used in more than one place but it can change and no need to change this value in each place we use in. also constants is very useful for default values for properties or calculations instead of writing them every time. File path , File Name , you will use in your app.
7th Jan 2017, 5:23 AM
Ahmad Hamdan
Ahmad Hamdan - avatar