In C, data types specify the type of data that you can store in your program. For example, if you want to store a number like 5, then you need to define a data type called int. If you want to store a string like cappuccino, then you need to create a data type called char*. A data type defines the size of the memory required to store the data, and also tells the compiler how to interpret the bits stored in that memory.

Main data types in C

Following are the five primitive or primary data types in the C programming language:


1. Integers - We use these to store various integers such as 5, 8, 67, 2390, etc.


2. Characters - Refers to all ASCII character sets as well as individual letters such as "x", "Y", etc.


3. Double - This includes all large numeric types that are not floating point data types or integer data types. Visit Double Data Types in C to learn more.


4. Floating-point numbers - any real value or decimal point, such as 40.1, 820.673, 5.9, etc.


5. Void – This word refers to having no value at all. We mainly use this data type when defining functions in a program.

different data type values


The size of a particular type of data in a program depends largely on the processor type as well as the compiler. In simple terms, the size of the data type depends entirely on the computer we run the C language on and the version of the C program compiler we have installed on the computer.


The int data type can be 4 bytes/2 bytes.


It is easy to remember the size of the int data type. The size specified generally corresponds to the word size of the program execution environment. In other words, in the case of a 16-bit environment, an int is 2 bytes or 16 bits. However, in a 32-bit environment, an int is 4 bytes, or 32 bits.


Char data type is 1 byte.


The size of the char data type is always 8 bits or 1 byte. Different compilers and interpreters do not change. This means that the type of compiler or processor used has nothing to do with its size.

The double data type is 8 bytes.


The size of a double data type is always 64 bits or 8 bytes. It is capable of storing twice the size in bytes that a floating-point data type can store. That's why it's called a double.


Considering a total of 64 bits, the program has 1 bit for the sign, 11 bits for the exponent, and the remaining 52 bits for the mantissa.


This data type can hold approximately 15 to 17 digits, both after and before the decimal point of the data type.


The floating point data type is 4 bytes.


The size of a floating-point data type is always 32 bits or 4 bytes. The floating point data type is inherently single precision and we use it to hold decimal values. It helps to store all kinds of large values, but Float is faster than Double. This is because double is suitable for relatively large data values. Hence it is relatively slow.

Data Type Modifiers in the C Programming Language

There are basically four modifiers for all data types used in the C language. We use these with all basic data types to further categorize them.


For example, if we say that there is a candy cane on the table, our interlocutor knows that there is a candy cane on the table. However, if we specifically say that there is a dark or milk chocolate bar on the table, it becomes more clear and specific to the person listening.


In a very similar way, modifiers in C help make primary or primitive data types more specific.

There are several modifiers here:


short

long

unsigned

sign

As the names here suggest, we use the unsigned and signed modifiers to represent unsigned (+ only) and signed (- and +) values ​​in any data type. Additionally, the short and long modifiers affect the range of values ​​for specific data types.