Constants
in c language constants and variables are frequently used.lets suppose
x=10
here x is a variable and 10 is constant.
mean that x can be assigned different value and x is variable.
Real Life example:
Suppose you have a blank Page and you write your name on it, now here that Page is variable and your name is constant because your name John will always remain constant. Now if you write your best friends name AJ Jadoon on that page.Aj Jadoon will be Constant because it cannot be changed but page is Variable.Constant is that thing which cannot be changed 10 Will remain always 10.
Variable is that thing whose value can be changed. x can be assigned a value 1,2,3 or whatever you want.
Types of Constants in C programming
There are two types of constants in C language we will focus on Primary constants only1. Primary constants
Integer constants
In integer constants we cannot use the numbers which have DECIMAL ( . )
and in c language we use ( int ) to declare integer constant.
Example int x=10
its range is from -32768 to 32767
Real constants
Real constants are those which contain Decimals. in c programming we use word float to declare real constant.
Example float x=10.22
Character Constant
Character constants are those which can store different characters in them like + , - , H etc.
we use word char to declare character constants.
example char x='A'
or
char x='+'
Note: character constant can only contain single alphabet,digit or symbol and it must be enclosed in single inverted comma.for example '+' , 'h', '*' etc
You will get familiar with their use in next examples