Programming in C, const qualifier
Question1: Explain what is const qualifier?
Ans: The const qualifier is used with a data type of declaration to specify a constant value.
Some examples of const qualifiers are:
Const int COUNT=5;
Const float PI=3.14;
The same thing can also be achieved using #define preprocessor as given below.
#define COUNT 5
#define PI 3.14
In most of the situations there is no difference between using define or const qualifier. The only difference is define is a preprocessor directive that simply replaces a symbol with a constant value throughout the program.
The const qualifier declares a variable type and assigns it a constant value. It has advantage at advance level of programming in C language.
Comments
Post a Comment