Constant:
Constant is a permanent value that cannot be changed. In C++ constant can be declared by using const keyword.
Types of constant:
1. Numeric
- int constant
- float constant
- string constant
- character constant
const int g =9.8;
If you change the value of constant after initialization an error will be generated by the compiler cannot modify const object.
#define:
#define is also used to define a constant.
General syntax:
#define constant_name value
Example: #define pai 3.14
No comments:
Post a Comment