Introduction of C Constants
C constants refers to the data items that do not change their value during the program execution. Several types of C constants that are allowed in C are:
Constant | Type of Value Stored |
---|---|
Integer Constant | Constant which stores integer value |
Floating Constant | Constant which stores float value |
Character Constant | Constant which stores character value |
String Constant | Constant which stores string value |
How to Declare Constant in C :-
We can declare constant using const variable. Suppose we need to declare constant of type integer then we can have following two ways to declare it –
const int a = 1; int const a = 1;
above declaration is bit confusing but no need to worry, We can start reading these variables from right to left. i.e
Declaration | Explanation |
---|---|
const int a = 1; | read as “a is an integer which is constant” |
int const a = 1; | read as “a is a constant integer” |
Introduction of C Constants
Reviewed by ANAND PANDEY
on
7:53:00 AM
Rating:
No comments: