Homecpp What is Constant in C++ Difference between Variable and Constant Muhammad Nawaz May 16, 2020 0 Comments Facebook Twitter ConstantIn the case of a variable, you can re-store a new value. However, in the case of constant, once a value is stored in it, cannot be changed. This is the difference between variable and constant. Constant declaration and initializationConstant can be declared in two ways:-Before the main function #define PI 3.14Inside main function (C++ const keyword is used) const int pi=3.14; C++ Program to use Constant:c++ constOutput:c++ const output Tags cpp Facebook Twitter
Post a Comment