Built-in Data Types in C for Data Structure: Types, Size & Examples

Chapter 3 • Data Structure

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.

✓ Simple Language ✓ Memory Size ✓ C Programs ✓ Pictorial Explanation ✓ Exam Questions
Quick Answer

What are Built-in Data Types in C?

Built-in Data Types in C for Data Structure: Types, Size & Examples

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.

💡
Why do C data types feel confusing at first?

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.

Chapter Navigation

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.

Value → Choose Data Type → Memory Allocation → Store & Process
Simple C Example
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.

Built-in Data Types in C
Integer int
Character char
Floating Point float, double
Void no value

C also provides _Bool for Boolean values and allows integer types to be modified using short, long, signed and unsigned.

Exam Note: In many university books, int, char, float and double are called basic data types or primitive data types in C. Terminology may vary slightly between textbooks, but the core idea remains the same.

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.

Integer Example
int students = 60;
int marks = 85;
int temperature = -5;

Here, all three values are whole numbers, so int is suitable.

Common Integer Variations

int

int

Used for normal whole-number values.

S

short int

An integer type whose minimum required range is smaller than or equal to int.

L

long int

Used when a wider integer range may be required.

LL

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.

Character Example
char grade = 'A';
char section = 'B';
char symbol = '#';

A char value is normally written inside single quotation marks.

Pictorial Example

'A' Character
'7' Character Digit
'#' Symbol
1 Byte sizeof(char) is always 1
Important Technical Point: In C, sizeof(char) is always 1 byte. However, a C byte is defined in terms of the implementation and contains at least 8 bits.

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 Example
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 Example
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 bytes

double

Commonly uses more memory and provides higher precision.

Typical size: 8 bytes

Boolean Data Type in C

Standard C provides the type _Bool for Boolean values. A Boolean value represents true or false conditions.

Using _Bool
_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.

Readable Boolean Example
#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 Function Example
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.

S

short

Used with integer types to provide a short integer type.

L

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 and Unsigned Example
signed int temperature = -10;
unsigned int students = 120;

Short and Long Int in C

Integer Modifier Examples
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
Very Important for Exams: Do not write that int is always 4 bytes or long is always 8 bytes. A safer answer is: "The exact size of C data types is implementation-dependent; common modern sizes are shown above."

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.

Check Data Type Size 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.

Write Data Type → sizeof(type) → Compiler Checks → Size in Bytes

C Data Types with Examples

Complete Beginner Example
#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 int marks[5]
🔗 Linked List int data
📚 Stack char item
🚶 Queue int processId
🌳 Tree int key
🕸️ Graph float weight
🪪 Student Record char name[]
💰 Application double amount

Array Example

Integer Array
int marks[5] = {70, 85, 90, 76, 88};

Here, every element of the Array stores an int value.

Structure Example

Different Data Types in One Student Record
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

Memory Trick: C I F D V

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

int is always 4 bytes

Not guaranteed. Four bytes is common, but the actual size depends on the C implementation.

char means only alphabet letters

No. char can represent characters such as letters, digits and symbols.

float and double are exactly the same

No. Double has at least as much precision as float and commonly provides much more precision.

unsigned int stores negative values

No. Unsigned integer types represent non-negative values.

void stores a normal value

No. void represents the absence of a value or type information in certain contexts.

Data types are unrelated to Data Structure

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.

2 Marks

1. What is a Data Type in C?

A data type specifies the kind of value a variable can store and helps the compiler determine how that data should be represented and processed.
2 Marks

2. Name the basic built-in data types in C.

Common basic built-in data types are char, int, float, double and void. Standard C also provides _Bool for Boolean values.
2 Marks

3. What is the use of int in C?

int is used to store whole-number values such as 10, 50, 0 and -25.
2 Marks

4. What is the use of char?

char is used to store a single character such as 'A', '5' or '#'.
2 Marks

5. What is void in C?

void represents the absence of a value and is commonly used for functions that do not return a value.
2 Marks

6. What is the sizeof operator?

sizeof is an operator that gives the size in bytes of a data type or object on the current C implementation.
2 Marks

7. What is an unsigned integer?

An unsigned integer represents only non-negative integer values.
5 Marks

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.

5 Marks

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.

5 Marks

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.

5 Marks

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.

10 Marks

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.

10 Marks

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

1. Which data type is normally used to store a whole number?
  1. float
  2. int
  3. void
  4. char array only
Correct Answer: B. int
2. Which data type stores a single character?
  1. char
  2. float
  3. double
  4. void
Correct Answer: A. char
3. Which type generally provides more precision than float?
  1. char
  2. int
  3. double
  4. void
Correct Answer: C. double
4. Which modifier is used for non-negative integer values?
  1. signed
  2. unsigned
  3. void
  4. float
Correct Answer: B. unsigned
5. Which operator is used to find the size of a data type?
  1. size
  2. length
  3. sizeof
  4. memory
Correct Answer: C. sizeof
6. What does void represent?
  1. A decimal number
  2. A character
  3. Absence of a value
  4. A negative integer only
Correct Answer: C. Absence of a value
7. Which of the following is a valid declaration?
  1. int age = 20;
  2. int = age 20;
  3. age int = 20;
  4. integer age := 20;
Correct Answer: A. int age = 20;
8. What is sizeof(char) in C?
  1. Always 1 byte
  2. Always 2 bytes
  3. Always 4 bytes
  4. Always 8 bytes
Correct Answer: A. Always 1 byte
9. Which is commonly used to store a decimal value?
  1. float
  2. void
  3. char only
  4. short only
Correct Answer: A. float
10. Which statement is correct?
  1. int is always exactly 4 bytes in C
  2. All C data types have the same size
  3. Exact type size can depend on implementation
  4. char cannot store symbols
Correct Answer: C. Exact type size can depend on implementation

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

int
Stores whole-number values.
char
Stores a character and has sizeof 1 byte.
float
Stores floating-point values.
double
Floating-point type with greater precision than float on common systems.
void
Represents absence of a value.
_Bool
Represents Boolean values.
signed
Supports negative and non-negative integer values.
unsigned
Supports non-negative integer values.
short / long
Modify integer type range requirements.
sizeof
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.

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Join Telegram Exam updates and free resources