Constants
Constants store a value that cannot be changed from their initial assignment. To declare a constant, use the const modifier.
For example :
const double PI = 3.14;
The value of const PI cannot be changed during program execution.
For example, an assignment statement later in the program will cause an error.
const double PI = 3.14;
PI = 8; // error
Constants must be initialized with a value when declared.
Constants store a value that cannot be changed from their initial assignment. To declare a constant, use the const modifier.
For example :
const double PI = 3.14;
The value of const PI cannot be changed during program execution.
For example, an assignment statement later in the program will cause an error.
const double PI = 3.14;
PI = 8; // error
Constants must be initialized with a value when declared.
No comments:
Post a Comment