
Education Journalist | Study Abroad Lead
The data types are one of the important features in the C programming language that uses data types with variables and functions.
- The data type in C has a variable that has an associated data type.
- The variable can store specific types of data like floating, string, integer, double, etc.
- The data type of a data is the collection of values that have fixed values, which means its characteristics.
Key terms: Data Type in C, Structure, Union, Typedef, enum
Purpose of Data Types in C
[Click Here for Sample Questions]
The data type defines operations that can safely be performed to transform, create, and use the variable in another computation. The space allocated in storage and the interpretation of the stored bit pattern are determined based on the type of variable used in a program.
Example Of Data Types In C: The compiler in the C language treats these aspects differently, which is why we utilize various data types to specify the desired data characteristics within the program.
Types of Data type in C
[Click Here for Sample Questions]
There are following basic data types in the C programming language such as:
- Primary
- Derived
Primary Data Types
[Click Here for Sample Questions]
These are the data types that are standard data types that the C language defines. These comprises four basic types of data types:
- char – A data type that occupies a single byte and is used for storing a single character from the local character set.
- float: These are single-precision floating-point data types.
- int: These represent integers and typically match the natural size of integers on the host machine.
- double: These are double-precision floating-point data types.

Data Types in C
User-Defined Data Types In C
These are the following types of user-defined data types in C programming language:
- Structures
- Union
- Typedef
- enum
Structures
Each data type within a structure is referred to as a member or field. These structure data types comprise objects of specific types.
The syntax for structure is as follows:
struct name of structure type
{
data type1 variable_name2;
data type2 variable_name2;
};
Example:
struct school
{
string name;
int marks;
};
Union
It is a collection of data types that are not similar to each other and are present in C language. It contains many members but only one member can be accessed at a particular time. The keyword ‘union’ means to create a union data type.
The syntax for defining a union data type is as follows:
union name of the union type
{
data type1 variable_name1;
data_type2 variable_name2;
};
Example:
union class
{
string name;
int marks;
};
Typedef
It is used to create an alternate or alias name for a data type already existing whereas the keyword Typedef r is used in C programming involving referencing existing data without generating any new entries.
The syntax for defining a typedef is as follows:
typedef existing_data_type alias_name;
Example:
void main()
{
typedef float decimal;
decimal weight= 58.9;
}
Enum
Each data type consists of sets of values known as elements and referred to as an enumerated data type. It usually gives symbolic names to represent a list of constants that are related to each other.
The syntax of defining enum data type is as follows:
enum variable_name(value1, value2, value3,….. value n);
Example:
enum bool
{
true,
false
};
Size of Primary Data Types
[Click Here for Sample Questions]
Here is a list of all the primary data types:
| Type | Range | Size (in bytes) |
|---|---|---|
| unsigned char | 0 to 255 | 1 |
| signed char or char | -128 to +127 | 1 |
| unsigned int | 0 to 65535 | 2 |
| signed int or int | -32,768 to +32767 | 2 |
| unsigned short int | 0 to 65535 | 2 |
| signed short int or short int | -32,768 to +32767 | 2 |
| unsigned long int | 0 to +4,294,967,295 | 4 |
| signed long int or long int | -2,147,483,648 to +2,147,483,647 | 4 |
| long double | 3.4E-4932 to 1.1E+4932 | 10 |
| double | 1.7E-308 to 1.7E+308 | 8 |
| float | 3.4E-38 to 3.4E+38 | 4 |
Different Data Type Values
[Click Here for Sample Questions]
The different type of values refers to the type of mathematical, relational or logical operations that can be applied without causing an error.
| Data type | Used for | Examples |
|---|---|---|
| String | Alphanumeric characters | hello worldAliceBob123 |
| Integer | Whole numbers | 712999 |
| Float (floating point) | Numbers with a decimal point | 3.159.0600.13 |
| Character | Encoding text numerically | 97 (in ASCII, 97 indicates a lowercase a) |
| Boolean | Representing logical values | TRUEFALSE |
Data Type Modifiers in C Programming Language
[Click Here for Sample Questions]
There are four types of modifiers for all data types used in C language. The C language helps in making the primary or primitive data types more specific.
Some of the modifies are mentioned below:
- short
- long
- unsigned
- signed
Range Of Values of C Data Type
[Click Here for Sample Questions]
The C language data type range are mentioned below:
| Data Type | 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 int 16 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 long long 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 |
When The Value of The Data Type Happens to Be Out of Range
[Click Here for Sample Questions]
To understand this check an example:
#include <stdio.h>
int main() {
// the maximum value allowed in the signed short int is 43568
signed short int x = 43767;
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 = 43767;
Read More: Tree Topology
Derived Data Types in C
[Click Here for Sample Questions]
Derived data types in C used to store complex types of data, they are several types of derived data types in C language:
- The 'char' Data Type: The ‘char’ data type is basically 8 bits or 1 byte. Different compilers and interpreters do not vary.
- The 'float' Data Type: The ‘float’ data type is basically 32 bits or 4 bytes., it is single-precision in nature, and there are uses for holding decimal values.
- The 'double' Data Type: The ‘double' data type is basically 64 bits or 8 bytes, it is capable of storing values that are comparatively double the size of the bytes that of 'float' data type.
- The 'int' Data Type: The ‘int' will be 2 bytes or 16 bits, it is generally equal to the length of the word of the program’s execution environment.
Use Of C Data Types
[Click Here for Sample Questions]
The C data type is to define the type of data that we use in a program.
Integer Data Type
Range: -2,147,483,648 to 2,147,483,647
Size: 4 bytes
Format Specifier: %d
Syntax: int var_name;
Character Data Type
Range: (-128 to 127) or (0 to 255)
Size: 1 byte
Format Specifier: %a
Syntax: char var_name;
Float Data Type
Range: 1.2E-38 to 3.4E+38
Size: 4 bytes
Format Specifier: %f
Syntax: float var_name;
Double Data Type
Range: 1.7E-308 to 1.7E+308
Size: 8 bytes
Format Specifier: %lf
Syntax: double var_name;
Solved Examples
[Click Here for Sample Questions]
Ques 1: Which of the following are data types used in C programming?
- Integer
- Character
- Floating-Point
- Void
Solution:
- 1, 3, and 4
- 2, 3, and 4
- 1, 2, and 3
- All of the Above
Ques 2: Which of the following are basic or primitive data types?
- Integer
- Character
- Double
- Floating-point
- Void
Solution:
- 1, 3, and 5
- 2, 4, and 5
- 1, 2, and 4
- All of the Above
Ques 3: The character data type ranges from:
- -63,586 to 63,586
- -127 to 127
- -50 to 50
- It has a huge range. There is no limit.
Solution: A. -63,586 to 63,586
Things to Remember
- Context switching is a process to be switched from the CPU so that another process can run.
- The character data type allows you to store only a single character in a variable in a C program.
- The storage size of the char data type is about 1 byte.
- Double data type also has a limit of 10 digits.
- The float has a storage size of about 4 bytes.
- The int data types do not allow you to store the decimal values.
- The storage size of the int data type can be 2 bytes, 4 bytes, or even 8 bytes.
Read More:
Sample Questions
Ques: What is the difference between structure and union? (2 marks)
Ans: Among the four user-defined data types in C, structure and union are very similar in nature; however, there exist a few differences between the two. A structure member’ can be accessed altogether simultaneously, while the members of the union cannot be accessed together. Union allows only one member to be accessible at a time.
Ques: What can all primitive data types be used by the user-defined data types in C? (1 mark)
Ans: The user-defined data types in C can use all the available primitive as well as derived data types in C. There is no bar on the usage of primitive types inside user-defined data types in C.
Ques: What are the different User-Defined Data Types in C? (2 marks)
Ans: User-Defined Data Types in C are the data types that are defined by users from the already existing data types. They are of the following types:
- Structures
- Union
- Typedef
- enum
Ques: What is the advantage of having user-defined data types in C? (2 marks)
Ans: The advantage of user-defined data types is to provide features and functionality for the programmer to code efficiently. It helps the programmer to build a more readable code and minimize the memory access time.
Ques: What are the varieties of Basic Data Types in C? (3 marks)
Ans: There are four major types of basic data types in C – both in unsigned and signed forms. These include:
- char: This data type is single-byte and can store a single character from the local character set.
- float: These are single-precision floating-point data types.
- int: Representing integers, they typically match the natural size of integers on the host machine.
- double: These are double-precision floating-point data types.
Ques: What are the features of Char Data Type? (3 marks)
Ans: There are following features of Char data type:
- The character data type allows you to store only a single character in a variable in a C program.
- The storage size of the char data type is about 1 byte.
- The character data type is represented in a program using the ‘char’ data type.
- For instance, we can store ‘X’ with the use of the char data type. But we cannot store more than one value here, because the char data type won’t support it.
- A string of various characters will be created if we try to create an array of the char data types in any program. This string will then store every value individually.
Ques: What are the key features of the Float Data Type? (3 marks)
Ans: There are following features of the Float Data Type:
- The float data type is used to store all decimal values in a program, but it has some storage limits.
- The float has a storage size of about 4 bytes. However, it varies significantly depending on the processor present in the CPU, similar to the int type.
- Using the float data type, you can store values that have up to 6 digits after the decimal point. For example, you can store the value 12.345678 in a variable if you use the float data type.
Ques: What are the key features of the Integer Data Type? (5 marks)
Ans: There are following features of the Integer Data type:
- The int keyword is used to refer to the integer data type in a C program.
- The int data type allows a variable in a program to store various numeric values.
- The storage size of the int data type can be 2 bytes, 4 bytes, or even 8 bytes.
- The size largely depends on the processor used to run the program. For example, when using a 16-bit processor, the int data type will be allocated with about 16 bits or 2 bytes of memory.
- Similarly, the int data type will be allocated with about 32 bits or 4 bytes for a 32-bit processor and 64 bits or 8 bytes of memory for a 64-bit processor.
- The int with 4 bytes of memory can store values ranging from -2,147,483,648 to +2,147,483,647.
- The int with 2 bytes of memory can store values ranging from -32,768 to +32,767.
- If you want to use an integer value that exceeds the maximum limit for the int, you can use the long int or long int. These data types have a very high limit for the values that can be stored.
For Latest Updates on Upcoming Board Exams, Click Here: https://t.me/class_10_12_board_updates
Check-Out:






Comments