2
Data Types and Data Type Modifiers for C Programming Language
Below are the fundamental (or basic) data types of C:
- int – used for storing integers
- char – used for storing individual characters
- float – used for storing floating point of decimal numbers
- double – used for storing more decimal points than float
- void – special data type only for functions and pointers
When I was learning C++ two years ago, I couldn’t differentiate between float and double. After countless examples that I saw today, I finally understand the difference between these two. As I defined above, the float data type is used to storing short decimal points, like price which has two decimal points. The double data type is used to storing long decimal points, like pi or infinite decimal points.
The data type modifiers that I learned today are following:
- short, long – used only for int (integers), to change size of the data type for save memory space
- unsigned, signed – also used only for int. Unsigned modifies int to positive number range. Signed is the default modifier for all of the data types.
- There are more modifiers, but I only learned these two groups today.
Since these modifiers only work for integer data type, int can be removed when declaring the variable with the modifiers. For example:
int age;Â Â Â Â Â Â Â Â Â Â Â // No data type modifiers long age;Â Â Â Â Â Â Â Â Â Â // With modifiers unsigned age;Â // With modifiers