In the C programming language, data types are used to define variables and functions. A data type is a classification that specifies the type of value that a variable can hold. For example, an integer variable can hold an integer value, and a character variable can hold a character value.

In addition to data types, C also provides modifiers that can be used to change the behavior of a data type. These modifiers are used to modify the size, sign, and precision of a data type. In this blog, we will discuss the different data type modifiers in C.

  1. Size Modifiers C provides four size modifiers that can be used to modify the size of a data type. They are:
  • short: This modifier is used to reduce the size of an integer variable to 2 bytes.
  • long: This modifier is used to increase the size of an integer variable to 4 bytes. It can also be used with a floating-point variable to increase its precision.
  • long long: This modifier is used to increase the size of an integer variable to 8 bytes.
  • unsigned: This modifier is used to make an integer variable unsigned, which means it can only hold positive values.
  1. Sign Modifiers C provides two sign modifiers that can be used to modify the sign of a data type. They are:
  • signed: This modifier is used to make an integer variable signed, which means it can hold both positive and negative values. This is the default sign for an integer variable.
  • unsigned: As mentioned earlier, this modifier is used to make an integer variable unsigned, which means it can only hold positive values.
  1. Precision Modifiers C provides one precision modifier that can be used to modify the precision of a floating-point variable. It is:
  • double: This modifier is used to increase the precision of a floating-point variable to 8 bytes.

Let's take an example to understand the use of data type modifiers in C.

In this example, we have defined five variables of different data types with modifiers. We have used the sizeof operator to print the size of each variable in bytes. The output of this program will be:

As we can see, the size of the integer variables changes with the use of size modifiers, and the precision of the double variable increases with the double modifier.