Modifier in C

The c compiler provides four reserve word named signed,unsigned,short and long are known as modifier.
A modifier is mainly used for modify type and size of variable.
  ð Modifier with char datatype
A char datatype mainly allowed only two modifier named signed and unsigned.
(a)    signed with char
When we define a variable without any modifier then variable bydefault preceded by signed modifie.
When a variable preceded by signed modifier then it ensures that a left most bit reserved for sign(+ve/-ve)
Example:-signed char ch;
                       or
                       signed char ch;


                                [0à -ve, 1à +ve]
range = -128 to 127

(a)    unsigned with char
When a variable preceded by unsigned modifier manually then it ensure that left most bit free for  sign(-ve/+ve).
                   When  a variable preceded by unsigned then it can store only positive value.
Example:-  unsigned char ch;
range= 0 to 255

NOTE:- If we try to use short or long modifier with variable then it doesn’t change type or size of variable.
  ð Modifier with int datatype
A datatype int allow all modifier i.e signed , unsigned, short and long.
(a)    signed with int
Example:-       signed int a;
                           or
                           signed int a;
                           signed a;
range = -32768 to 32767

(b)     unsigned with int
Example:- unsigned int a;
                        or
                        unsigned a;
range= 0 to 65535
(c)    short with int
When a variable preceded by short modifier then it ensure thatit can be used for bit operation. A short modifier doesnot change capacity of variable.
Example:-  short int a;
                                        or
                        short signed int a;
range = -32768 to 32767
(d)    long with int (%ld)
When a int type variable preceded by long modifier then it specify / allocates 4 bytes memory space.
Example:-  long int a;
                                          
                range = -2147483648 to 2147483647
  ð Modifier with float
A float datatype only allowed two modifier named short and long . It doesn’t allow signed or unsigned ,if we try to use signed or unsigned modifier with float then it leads to compile time error.
(a)    short with float
Example:- short float n;
                        or
                        short signed float n;
(b)   long with float
When float type variable preceded by long modifier then it specifies or allocates 8 byte memory space.
Example:- long float a;
  ð Modifier with double
A double datatype also only allowed two modifier named short and long. It doesn’t allow signed or unsigned.
(a)    short with double
Example:- short double n;
                        or
                        short signed double n;
(b)   long with double
When double type variable preceded by long modifier then it allocates 10 bytes memory space.
Example:- long double n;

Comments

Popular Posts