C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

What is the difference between constants and read-only variables that are used in programs?

0 votes
20 views
asked by john Guru (27,140 points)

1 Answer

0 votes
Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are
 
Constants:
Constants are dealt with at compile-time.
Constants supports value-type variables.
Constants should be used when it is very unlikely that the value will ever change.
 
Read-only:
Read-only variables are evaluated at runtime.
Read-only variables can hold reference type variables.
Read-only variables should be used when run-time calculation is required.
 
answered by sara Guru (24,570 points)

Related questions

0 votes
1 answer 25 views
0 votes
1 answer 138 views
138 views asked by shivani Sr Member (1,090 points)
0 votes
1 answer 31 views
0 votes
1 answer 386 views
...