Qualifiers
Qualifiers alters the meaning of base data type to yield a new data type.
Size qualifiers:
Size qualifiers alters the size of basic data type. The keywords long and short are two size qualifiers. For example:
long int i;
The size of int is either 2 bytes or 4 bytes but, when long keywords is used, that variables will be either 4 bytes of 8 bytes. Learn more about long keywords in C programming. If the larger size of variable is not needed then, short keywords can be used in similar manner as long keyword.
Sign qualifiers:
Whether a variables can hold only positive value or both values is specified by sign qualifiers. keywords signed and unsigned are used for sign qualifiers.
unsigned int a;
// unsigned variable can hold zero and positive values only
It is not necessary to define variables using keyword signed because, a variables is signed by default. Sign qualifiers can be applied to only int and char data type. For a int variable of size 4 bytes it can hold data from -231 to 231-1 but, if that variable is defined unsigned, it can hold data from 0 to 232 -1.
Constant qualifiers
Constant qualifiers can be declared with keywords const. An object declared by const cannot be modified.
const int p=20;
The value of p cannot be changed in the program.
Volatile qualifiers:
A variables should be declared volatile whenever its value can be changed by some external sources outside program. keywords volatile is used to indicate volatile variable.
data type
Qualifiers alters the meaning of base data type to yield a new data type.
Size qualifiers:
Size qualifiers alters the size of basic data type. The keywords long and short are two size qualifiers. For example:
long int i;
The size of int is either 2 bytes or 4 bytes but, when long keywords is used, that variables will be either 4 bytes of 8 bytes. Learn more about long keywords in C programming. If the larger size of variable is not needed then, short keywords can be used in similar manner as long keyword.
Sign qualifiers:
Whether a variables can hold only positive value or both values is specified by sign qualifiers. keywords signed and unsigned are used for sign qualifiers.
unsigned int a;
// unsigned variable can hold zero and positive values only
It is not necessary to define variables using keyword signed because, a variables is signed by default. Sign qualifiers can be applied to only int and char data type. For a int variable of size 4 bytes it can hold data from -231 to 231-1 but, if that variable is defined unsigned, it can hold data from 0 to 232 -1.
Constant qualifiers
Constant qualifiers can be declared with keywords const. An object declared by const cannot be modified.
const int p=20;
The value of p cannot be changed in the program.
Volatile qualifiers:
A variables should be declared volatile whenever its value can be changed by some external sources outside program. keywords volatile is used to indicate volatile variable.
data type
No comments:
Post a Comment