Mostly used powerful Datatypes in C

Good morning to all , here is my sixth blog before it i have covered some basics About C programming . Now we will discuss about Datatypes in C which are mostly used and are very useful in C programming. So here we start Firstly we discuss about what is data and then we will look at this topic.
Table of Contents
What is Data ?
A collection of information obtained through measurements, study, observations, or analysis is referred to as data.
Facts, numbers, names, figures, or even descriptions of things may be included. In the form of graphs, charts, or tables, data is arranged.
Data can we of many types but in C we discuss about the data in the form of integer , decimal , words , character etc.
Datatypes in C
A data type specifies the type of data that a variable can store such as integer, floating, character, etc.
Basically , there are four types of datatype in C that are : Basic type , Derived type , Enumeration type (User Defined) , Void type (Valueless) .

So from above figure we can easily find that each class have listed datatypes as below :-
Basic Datatype | int, char, float, double |
Derived Datatype | array, pointer, structure, union |
Enumeration Datatype (User Defined) | enum |
Void Datatype (Valueless) | void |
Bool Datatype | true, false |
They are described below :-
Sr.No. | Types & Description |
---|---|
1 | Basic Types ->They are arithmetic types and are further classified into: (a) integer types and (b) floating-point types. |
2 | Enumerated types ->They are again arithmetic types and they are used to define variables that can only assign certain discrete integer values throughout the program. |
3 | The type void ->The type specifier void indicates that no value is available. |
4 | Derived types ->They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types. |
In this article we only read about primitive data types .
Primitive Datatypes in C

The five basic datatypes found in the C programming language are as follows:
- Integer – These are used to store different whole numbers, including 5, 8, 67, 2390, etc.
- Character – This term includes all ASCII character sets in addition to individual alphabets like “x,” “Y,” etc.
- Double – These huge numeric value types that do not fall within either the floating-point or integer data types are included here. To learn more, go to Double Data Type in C.
- Floating-point – These are all the decimal points or real numerical values, such as 40.1, 820.673, 5.9, etc.
- Void – This term refers to no values at all. We mostly use this data type when defining the functions in a program.
The aforementioned datatypes are specified in a program using a variety of keywords. The keywords we employ are as follows:
Keyword Used | Datatype |
int | Integer |
float | Floating-point |
void | Void |
char | Character |
double | Double |
Each datatype’s size is specified in bytes or bits. Additionally, a very broad range of values can be stored in these data types.
Different Datatypes Values
The size of any particular datatype in a programme is greatly influenced by the compiler and kind of processor. To put it another way, the size of the data type fully depends on the machine that we are using to run the C language and the version of the C program compiler that we have installed.
Int datatype
- It can be of 4 bytes / 2 bytes .
- The size of the int datatype is extremely simple to recall. The supplied size typically corresponds to the program’s execution environment’s word length. In other words, if the environment is a 16-bit environment, int will be 2 bytes or 16 bits. In a 32-bit environment, however, int will be 4 bytes or 32 bits.
char datatype
- It is of 1 byte.
- The char datatype is essentially 8 bits or 1 byte in size. With several interpreters and compilers, no variance would exist. It implies that there will be absolutely no difference in its size depending on the compiler or processor utilised.
float datatype
- It is of 4 bytes.
- The float datatype is essentially 32 bits or 4 bytes in size. We utilise the single-precision float data type to store the decimal numbers because of its nature. Although it aids in the storage of very large values, floats are often faster than doubles. The reason for this is because double operates on comparably considerably larger data values. Thus, it moves more slowly in comparison.
double datatype
- It is of 8 bytes.
- The double datatype is essentially 64 bits or 8 bytes in size. It can store numbers that are roughly twice as large as what the float data type can store in terms of bytes. It is referred to as the double for this reason.
- The software employs 1 bit for sign representation, 11 bits for the exponent, and the remaining 52 bits for the mantissa, for a total of 64 bits.
- This data type can store up to 15–17 digits, both after and before the data type’s decimal.
void datatype
- It is of 0 bytes.
- The void datatype has no size at all because it has no purpose.
- All of these datatypes encompass a variety of values. But first, let’s take a closer look at the modifiers that are applied to the data types.
Format specifiers in C
In C, the format specifiers are utilised for both input and output. When collecting input using the scanf() function and publishing using the printf() method, the compiler can determine the type of data in a variable by applying this idea.
Here is a list of format specifiers.
Format Specifier | Type |
---|---|
%c | Character |
%d | Signed integer |
%e or %E | Scientific notation of floats |
%f | Float values |
%g or %G | Similar as %e or %E |
%hi | Signed integer (short) |
%hu | Unsigned Integer (short) |
%i | Unsigned integer |
%l or %ld or %li | Long |
%lf | Double |
%Lf | Long double |
%lu | Unsigned int or unsigned long |
%lli or %lld | Long long |
%llu | Unsigned long long |
%o | Octal representation |
%p | Pointer |
%s | String |
%u | Unsigned int |
%x or %X | Hexadecimal representation |
%n | Prints nothing |
%% | Prints % character |
Modifiers in C
For all of the datatypes used in the C language, there are essentially four types of modifiers. For further categorization, we employ these in addition to all the fundamental data kinds.
In a similar way, the modifiers in the C language assist in greatly increasing the specificity of the main or primitive data types.
Here are a few modifiers:
- short
- long
- unsigned
- signed
We utilize the unsigned and signed modifiers, as the names imply, to provide unsigned (only +) and signed (- and +) values for any given data type. Additionally, the value range of any particular data type is impacted by the short and long modifiers.
For instance, the C programming language accepts many perfectly acceptable data types, such as long int, short int, unsigned int, signed int, etc.
Range of Values of C Datatypes
Datatype | Format Specifier | Minimal Range | Typical Bit Size |
unsigned char | %c | 0 to 255 | 8 |
char | %c | -127 to 127 | 8 |
signed char | %c | -127 to 127 | 8 |
int | %d, %i | -32,767 to 32,767 | 16 or 32 |
unsigned int | %u | 0 to 65,535 | 16 or 32 |
signed int | %d, %i | Same as int | Same as int16 or 32 |
short int | %hd | -32,767 to 32,767 | 16 |
unsigned short int | %hu | 0 to 65,535 | 16 |
signed short int | %hd | Same as short int | 16 |
long int | %ld, %li | -2,147,483,647 to 2,147,483,647 | 32 |
long long int | %lld, %lli | -(263 – 1) to 263 – 1 (It will be added by the C99 standard) | 64 |
signed long int | %ld, %li | Same as long int | 32 |
unsigned long int | %lu | 0 to 4,294,967,295 | 32 |
unsigned longlong int | %llu | 264 – 1 (It will be added by the C99 standard) | 64 |
float | %f | 1E-37 to 1E+37 along with six digits of the precisions here | 32 |
double | %lf | 1E-37 to 1E+37 along with six digits of the precisions here | 64 |
long double | %Lf | 1E-37 to 1E+37 along with six digits of the precisions here | 80 |
The different ranges and combinations of the modifiers and data types provide a range of changing values, as you can see in the table above.
When printing any value of a variable in a program, one must use the format specifier. The printf() statement is where they have to do it.
When Value of data is out of range
The C language compiler will produce an error whenever we attempt to assign any value to a specific data type in a programme that is greater than the permitted value range.
To further grasp this, let’s look at an illustration.
int main() {
// the maximum value allowed in the signed short int is 32767
signed short int x = 34767;
return 0;
}
The generated output for this program would be:
warning: very large integer value implicitly truncated to signed type [-Woverflow]
signed short int x = 34767;
^
The software sets the int datatype as a default data type whenever we use a type modifier, even when we don’t use any data types. Here, signed would be equivalent to a signed int, unsigned to an unsigned int, short to a short int, and long to a long int.
Meaning of Unsigned as well as Signed
Unsigned
In essence, it is a little difficult to comprehend. To put it another way, the unsigned modifier refers to all positive values, while the signed modifier refers to both positive and negative numbers.
Every time a compiler receives a numeric value from the program, it turns that numeric value into a binary number. This indicates that it will consist of a variety of 1s and 0s. For example, the binary value of 1 is either 0001 or 01, the binary value of 2 is 0010, the binary value of 32767 is 01111111 11111111, and many more.
Signed
The highest bit of order or the first digit starting from the left in binary numbers is used as the sign flag when referring to signed integers. When the sign flag is set to 1, the number will always be negative. Conversely, whenever the sign flag is set to 0, it will be positive.
Additionally, since we utilize one bit to indicate whether a particular number is positive or negative, the program will require one less bit to represent the number. As a result, the range is relatively limited.
Purposes of Datatypes
The term “datatype” in the context of the C programming language refers to a comprehensive system that we employ to define different sorts of functions or variables in a program. Here, we decide how much storage space a variable will require and how the stored bit pattern will be interpreted based on the type of variable that the program contains.
The kind of data that a variable can contain, such as character, integer, or floating-point data, is specified by its data type.
Escape Sequence in C
An escape sequence in C language is a sequence of characters that doesn’t represent itself when used inside string literal or character.
It is composed of two or more characters starting with backslash \. For example: \n represents new line.
List of Escape Sequences in C
Escape Sequence | Meaning |
---|---|
\a | Alarm or Beep |
\b | Backspace |
\f | Form Feed |
\n | New Line |
\r | Carriage Return |
\t | Tab (Horizontal) |
\v | Vertical Tab |
\\ | Backslash |
\’ | Single Quote |
\” | Double Quote |
\? | Question Mark |
\nnn | octal number |
\xhh | hexadecimal number |
\0 | Null |
Summary
Here we learn all the types of datatypes in c , format specifiers , modifiers & Escape sequence used in C . Hope you loved and enjoyed this blog . Follow our site for more blogs like this.