Explained data types in C programming language in detail. All the data types in C language are covered in detail. The following are the data types in C language : int, float. char, double/
2. What is a Data Type?
• A data type is an attribute of a variable that determines the types of
data it can store and the operation that can be performed on it.
• Each programming language provides different data types to support
different types of data and operation.
• C is a strongly typed language which means all variable must have a
data type associated with them
• In C programming language, there are built-in data types that can be
used to define variable, as well as user-defined data types that can be
created using the struct keyword.
3. Built-in Data Types
• C language provide built-in data types to define variable.
• The following are the built-in data types in C:
Character
Integer
Floating Point
Double
4. Character
• The char data type is used to represent single characters such as 'a', 'b',
'c', etc.
• The size of char data type is 1 byte.
• The range of values for char data type is from -128 to 127 or 0 to 255.
• To create a variable of character data type:
char variable_name;
5. Integer
• The int data type is used to represent integer values such as 1, 2, 3, etc.
• The size of int data type is 2 or 4 bytes depending on the system
architecture.
• The range of values for int data type is from -32,768 to 32,767 for 2-
byte int, and from -2,147,483,648 to 2,147,483,647 for 4-byte int.
• There are other integer data types such as short, long, and long long,
with different sizes and ranges.
• To create variable of integer data type:
int variable_name;
6. Floating Point
• The float and double data types are used to represent floating-point
values such as 1.2, 3.14, etc.
• The size of float data type is 4 bytes and the size of double data type is
8 bytes.
• The range of values for float and double data types are system-
dependent.
• To create a variable of type float and double:
float variable_name;
double variable_name;
7. Void Data Type
• The void data type represents the absence of a value.
• It is used to specify that a function returns no value or that a pointer
points to no specific data type.
8. User Defined Data Type
• C language allows users to define their own data types using the struct
keyword.
• A struct is a collection of variables of different data types.
• A struct can be used to group related variables and make the code
more readable.