C modifiers
Modifier changes the meaning of the basic data type, generates new data types.Size modifiers
Size modifiers can change the size of the basic data type. There are two types of size modifiers in C programming
short
long
The following example shows the size modifiers:
long double i;
Double is double by 8 bytes. With the use of long keywords, the size of the variable becomes 10 bytes.
If you do not need the value of the variable too big, you can use the short keyword. For example:
short int a; // Captures 2 bytes of memory space for all operating systems.
Sign modifier
Both integers and floating point variables can accept positive and negative values. However, if you want to keep the value of the variable only positive then use the unsigned data type.
// unsigned variable can not have negative value
unsigned int positiveInteger;
There is also another modifier signed, which can have both positive and negative values. But there is no need to define it because the variable is signed by default.
An integer variable of 4 bytes can have a value of -231 to 231-1. But if the variable is defaced as unsigned, it can have a value of 0 to 232-1.
Remember, the sign modifier only applies to int and char data types.
Constant Modifier
Identifier can also be declared as a constant. For this const keyword is used.
const int age = 32;
The age variables will not be changed in the program.
Volatile Modifier
If you change the value of the variable with any external source of the program, the variable should be declarated as a volatile.

0 Comments