Built-in Data Types in C for Data Structure: Types, Size & Examples
Learn built-in data types in C for Data Structure in simple language. This chapter explains int, char, float, double, void, Boolean values, type modifiers, size, range, examples and how these C data types are used while creating Data Structures.
What are Built-in Data Types in C?
Built-in data types in C are the basic data types directly supported by the C language for storing different kinds of values. Important built-in or basic data types include char, int, float, double and void. C also provides _Bool for Boolean values and modifiers such as short, long, signed and unsigned.
Most students remember int for numbers, float for decimal values and char for characters, but confusion starts when short, long, signed, unsigned, double and memory size appear together. The easiest way is to first ask one question: What kind of value do I want to store? Once that is clear, choosing the correct data type becomes much easier.
This chapter is a beginner-friendly guide to built-in data types in C for Data Structure. It covers data types in C, C data types with examples, basic data types in C, primitive data types in C, size of data types in C and their use in Data Structure programs.
What is a Data Type in C?
A data type in C tells the compiler what kind of value a variable can store, how much memory may be required and what type of operations can be performed on that value.
int age = 21; float percentage = 87.5f; char grade = 'A';
Here, age stores a whole number, so int is used. Percentage contains a decimal value, so float is suitable. Grade contains one character, so char is used.
Why are Data Types Important?
Data types help the compiler understand the meaning of stored data. They also affect memory usage, valid values and the operations that can be performed.
Memory
Different data types may require different amounts of memory.
Value Type
A data type decides whether we store integers, decimals or characters.
Operations
The compiler knows which operations are valid for a particular value.
Types of Built-in Data Types in C
The main built-in data types in C can be understood using the following classification.
C also provides _Bool for Boolean values and allows integer types to be modified using short, long, signed and unsigned.
Integer Data Types in C
Integer data types in C are used to store whole numbers, meaning numbers without a fractional part.
Examples include: 10, 25, 0, -15 and 5000.
int students = 60; int marks = 85; int temperature = -5;
Here, all three values are whole numbers, so int is suitable.
Common Integer Variations
int
Used for normal whole-number values.
short int
An integer type whose minimum required range is smaller than or equal to int.
long int
Used when a wider integer range may be required.
long long int
Provides at least as much range as long and is commonly 64 bits.
signed int
Stores negative, zero and positive integer values.
unsigned int
Stores only non-negative integer values and provides a larger positive range.
Char Data Type in C
The char data type in C is used to store one character.
char grade = 'A'; char section = 'B'; char symbol = '#';
A char value is normally written inside single quotation marks.
Pictorial Example
Floating Point Data Types in C
Floating point data types in C are used when values contain a fractional or decimal part.
Float
The float data type in C is commonly used for decimal values when moderate precision is enough.
float percentage = 87.5f; float price = 199.50f;
Double
The double data type in C stores floating-point values with greater precision than float on common systems.
double pi = 3.141592653589793; double distance = 98765.4321;
Float vs Double in C
float
Commonly uses less memory and provides lower precision.
Typical size: 4 bytesdouble
Commonly uses more memory and provides higher precision.
Typical size: 8 bytesBoolean Data Type in C
Standard C provides the type _Bool for Boolean values. A Boolean value represents true or false conditions.
_Bool isAvailable = 1; _Bool isDeleted = 0;
Here, 1 represents true and 0 represents false.
In programs that include <stdbool.h>, the names bool, true and false are commonly used for easier readability.
#include <stdbool.h> bool isEmpty = true;
Void Data Type in C
The void data type in C represents the absence of a value.
It is commonly used with functions that do not return a value.
void displayMessage() {
printf("Data Structure");
}
This function performs an action but does not return any value.
You may also see void * in advanced C programs. A void pointer can hold the address of different object types, but it must be handled carefully.
Type Modifiers in C
Type modifiers in C modify the range or representation of basic integer and floating-point types.
short
Used with integer types to provide a short integer type.
long
Used to provide a longer integer type or long double.
signed
Allows both negative and non-negative integer values.
unsigned
Represents only non-negative integer values.
Signed and Unsigned in C
Signed
Can represent negative, zero and positive values.
Example: -50, 0, 50
Unsigned
Represents zero and positive values only.
Example: 0, 50, 100
signed int temperature = -10; unsigned int students = 120;
Short and Long Int in C
short int x = 100; long int population = 500000L; long long int distance = 9000000000LL;
Size of Data Types in C
The size of data types in C is an important exam and programming topic. However, one point must be understood clearly: the C language does not guarantee the same byte size for every type on every machine.
Actual size depends on the compiler, processor and system architecture. The following table shows values commonly seen on modern systems.
| Data Type | Common Size | Example | Main Use |
|---|---|---|---|
| char | 1 byte | 'A' | Characters / small integer values |
| short int | Often 2 bytes | 120 | Smaller integer range |
| int | Often 4 bytes | 5000 | General whole numbers |
| long int | Often 4 or 8 bytes | 500000L | Larger integer values |
| long long int | Often 8 bytes | 9000000000LL | Very large integer values |
| float | Often 4 bytes | 85.5f | Decimal values |
| double | Often 8 bytes | 3.14159265 | Higher-precision decimals |
| long double | Implementation-dependent | 3.14159L | Extended floating-point precision |
| _Bool | Implementation-dependent | 0 or 1 | Boolean condition |
Range of Data Types in C
The range of data types in C tells us the minimum and maximum values that a type can represent.
Exact ranges depend on the implementation. For a commonly used 8-bit char, 16-bit short and 32-bit int environment, examples are:
| Type | Common Example Range |
|---|---|
| signed char | -128 to 127 |
| unsigned char | 0 to 255 |
| signed short | -32,768 to 32,767 |
| unsigned short | 0 to 65,535 |
| signed int | Commonly -2,147,483,648 to 2,147,483,647 |
| unsigned int | Commonly 0 to 4,294,967,295 |
Instead of memorizing every number without understanding it, remember the main concept: unsigned types remove the negative range and use the available bit patterns for non-negative values.
sizeof Operator in C
The best way to check the actual size of a data type on your own computer is to use the sizeof operator in C.
#include <stdio.h>
int main() {
printf("char = %zu byte(s)\n", sizeof(char));
printf("int = %zu byte(s)\n", sizeof(int));
printf("float = %zu byte(s)\n", sizeof(float));
printf("double = %zu byte(s)\n", sizeof(double));
printf("long = %zu byte(s)\n", sizeof(long));
printf("long long = %zu byte(s)\n", sizeof(long long));
return 0;
}
The program prints the size used by your compiler and system. The result of sizeof is expressed in bytes.
C Data Types with Examples
#include <stdio.h>
int main() {
int rollNumber = 101;
char grade = 'A';
float percentage = 87.5f;
double fees = 45000.75;
unsigned int age = 21;
printf("Roll Number: %d\n", rollNumber);
printf("Grade: %c\n", grade);
printf("Percentage: %.1f\n", percentage);
printf("Fees: %.2f\n", fees);
printf("Age: %u\n", age);
return 0;
}
This simple program shows how different built-in C data types can store different kinds of student information.
Why are C Data Types Important in Data Structure?
Data types in Data Structure are important because every Array, Linked List, Stack, Queue, Tree or Graph eventually stores some type of data.
Array Example
int marks[5] = {70, 85, 90, 76, 88};
Here, every element of the Array stores an int value.
Structure Example
struct Student {
int rollNumber;
char grade;
float percentage;
};
This example shows why understanding built-in data types is necessary before studying advanced Data Structures in C.
How to Choose the Correct Data Type in C?
| Value to Store | Suitable Type | Example |
|---|---|---|
| Whole number | int | age = 21 |
| Single character | char | grade = 'A' |
| Decimal value | float | percentage = 85.5 |
| Higher-precision decimal | double | pi = 3.141592... |
| True/False condition | _Bool / bool | isEmpty = true |
| No returned value | void | void display() |
| Only non-negative integer | unsigned int | count = 100 |
Common Format Specifiers for C Data Types
When using printf and scanf, students should also know the common format specifiers associated with C data types.
| Data Type | Common printf Format | Example |
|---|---|---|
| int | %d | printf("%d", number); |
| unsigned int | %u | printf("%u", value); |
| char | %c | printf("%c", grade); |
| float | %f | printf("%f", percentage); |
| double | %f | printf("%f", value); |
| long int | %ld | printf("%ld", value); |
| long long int | %lld | printf("%lld", value); |
| size_t | %zu | printf("%zu", sizeof(int)); |
Easy Trick to Remember Basic C Data Types
Char → Int → Float → Double → Void
The trick is only for quick revision. In an exam, always explain each data type with its meaning and example instead of writing only the abbreviation.
Common Mistakes Students Make
Not guaranteed. Four bytes is common, but the actual size depends on the C implementation.
No. char can represent characters such as letters, digits and symbols.
No. Double has at least as much precision as float and commonly provides much more precision.
No. Unsigned integer types represent non-negative values.
No. void represents the absence of a value or type information in certain contexts.
Wrong. Data Structures use data types to define what their elements store.
Important Exam Questions on Built-in Data Types in C
These questions cover the important areas generally asked from built-in data types in C for Data Structure.
1. What is a Data Type in C?
2. Name the basic built-in data types in C.
3. What is the use of int in C?
4. What is the use of char?
5. What is void in C?
6. What is the sizeof operator?
7. What is an unsigned integer?
8. Explain basic data types in C with examples.
C provides different basic data types for storing different kinds of values.
int stores whole numbers, such as int age = 20. char stores a character, such as char grade = 'A'. float stores decimal values, such as float marks = 85.5f. double is used for floating-point values requiring greater precision.
void represents no value, while standard C also provides _Bool for Boolean values.
9. Explain type modifiers in C.
Type modifiers are used to modify the range or representation of basic C types.
The main modifiers are short, long, signed and unsigned. Signed integer types can represent negative and non-negative values, while unsigned types represent non-negative values.
Short and long allow different integer ranges according to the implementation. Examples include short int, long int, unsigned int and long long int.
10. Differentiate between float and double.
Both float and double are used for floating-point values. Float commonly uses less memory and provides lower precision.
Double commonly uses more memory and provides higher precision. On many systems, float is 4 bytes and double is 8 bytes, although exact sizes are implementation-dependent.
11. Differentiate between signed and unsigned data types.
A signed integer type can represent negative, zero and positive values.
An unsigned integer type represents only zero and positive values. Because it does not need a negative range, it can represent a larger maximum non-negative value using the same number of bits.
12. Explain Built-in Data Types in C with Types, Size and Examples.
A data type specifies the type of value that a variable can store. Built-in data types form the foundation of C programming and are also important while implementing Data Structures.
The main built-in data types include int, char, float, double and void. Standard C also provides _Bool for Boolean values.
int is used for whole numbers. char stores a character. float and double store floating-point values, with double generally providing greater precision. void represents the absence of a value.
C provides modifiers such as short, long, signed and unsigned to modify integer range or representation.
The exact size of a data type is implementation-dependent. On many modern systems, char is 1 byte, int is 4 bytes, float is 4 bytes and double is 8 bytes, but a program should use sizeof when it needs the actual size.
Built-in data types are used in Arrays, Linked Lists, Stacks, Queues, Trees and other Data Structures to define what kind of value each element stores.
13. Explain the Importance of Data Types in Data Structure with Examples.
Data types are important in Data Structure because every data element must have a representation in memory.
An Array may store int values such as student marks. A Stack may store char values when processing symbols. A Graph may store float or double values as edge weights.
In a Linked List, a node may contain an int data field. A student structure may combine int, char and float values.
Correct selection of data type improves clarity and ensures that the program can represent the required values properly.
Therefore, understanding C data types is an important foundation before learning implementation of Data Structures in C.
Built-in Data Types in C MCQs
- float
- int
- void
- char array only
- char
- float
- double
- void
- char
- int
- double
- void
- signed
- unsigned
- void
- float
- size
- length
- sizeof
- memory
- A decimal number
- A character
- Absence of a value
- A negative integer only
- int age = 20;
- int = age 20;
- age int = 20;
- integer age := 20;
- Always 1 byte
- Always 2 bytes
- Always 4 bytes
- Always 8 bytes
- float
- void
- char only
- short only
- int is always exactly 4 bytes in C
- All C data types have the same size
- Exact type size can depend on implementation
- char cannot store symbols
Important Viva Questions
| Question | Short Answer |
|---|---|
| What is a data type? | It defines the kind of value a variable can store. |
| Which type stores whole numbers? | int and other integer types. |
| Which type stores a character? | char. |
| What is float used for? | Floating-point or decimal values. |
| What is double? | A floating-point type with at least as much precision as float. |
| What does void mean? | Absence of a value. |
| What does unsigned mean? | The integer type represents non-negative values only. |
| What does signed mean? | The integer type can represent negative and non-negative values. |
| What does sizeof return? | The size of an object or type in bytes. |
| Is int always 4 bytes? | No. Its exact size is implementation-dependent. |
| What is sizeof(char)? | 1 byte. |
| Why are data types needed in Data Structure? | They define what values Data Structure elements store. |
Quick Revision
Stores whole-number values.
Stores a character and has sizeof 1 byte.
Stores floating-point values.
Floating-point type with greater precision than float on common systems.
Represents absence of a value.
Represents Boolean values.
Supports negative and non-negative integer values.
Supports non-negative integer values.
Modify integer type range requirements.
Finds actual type or object size in bytes.
Frequently Asked Questions
What are Built-in Data Types in C?
Built-in data types are basic types directly provided by C, including char, integer types, floating-point types and void. C also provides _Bool for Boolean values.
What are the Basic Data Types in C?
Common basic data types taught to beginners are char, int, float, double and void.
What is the Size of int in C?
The exact size of int depends on the C implementation. It is commonly 4 bytes on many modern systems, but programs should use sizeof(int) when the actual size is required.
What is the Size of char in C?
sizeof(char) is always 1 byte in C.
What is the Difference Between float and double?
Both store floating-point values. Double provides at least as much precision as float and commonly uses more memory.
What is the Difference Between signed and unsigned in C?
Signed integer types can represent negative and non-negative values. Unsigned integer types represent only non-negative values.
What are Type Modifiers in C?
Common type modifiers include short, long, signed and unsigned.
What is the sizeof Operator in C?
sizeof returns the size in bytes of a type or object for the current C implementation.
Why are Data Types Important in Data Structure?
Data types define what kind of values are stored inside Arrays, Linked Lists, Stacks, Queues, Trees and other Data Structures.
Which C Data Type Should I Use for Student Marks?
If marks are whole numbers, int may be suitable. If fractional marks such as 87.5 must be stored, float or double may be more suitable.
Conclusion
Built-in data types become much easier when you stop memorizing their names and first understand what kind of value each type is designed to represent. Whole numbers use integer types, characters use char, decimal values use floating-point types, Boolean conditions can use _Bool, and void represents the absence of a value.
In this chapter, we covered built-in data types in C for Data Structure, basic data types in C, primitive data types in C, integer data types in C, floating point data types in C, char data type in C, void data type in C, type modifiers in C, signed and unsigned in C, short and long int in C, size of data types in C, range of data types in C and the sizeof operator in C.
These concepts are directly connected with Data Structure because Arrays, Linked Lists, Stacks, Queues, Trees and other structures need data types to define what information their elements will store. Once this chapter is clear, understanding the next programming and Data Structure topics becomes much easier.
