How Many Type of Constant in C

What is constant? How many type of constant in C?

Ans:

Constant is fixed value which can not be changed by the program during the execution.
Constants are classified as

We can make any identifier constant by
const keyword:
e.g
const int total=5;
now total is constant.We cannot change the value of total.
define directive :
e.g
#define fraction 1.5
Preprocessor are processed before the actual compilation. So it paste will paste the 1.5 in place of fraction in the program before actual compilation.
enum keyword :
e.g
enum size { a=8,b=7,c,d,e};
now a,b,c,d and e are constant we cannot change the value of a by program.

0 comments:

Post a Comment