Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Data Types in C:

Meaning of data types , their types , characterstics , size ,uses and


examples

SUBMITTED BY- PRIYA VERMA

ROLL NO.- 1230755029

CLASS- BCA(A) FIRST YEAR


Meaning of Data Types
1 Definition 🔍
ata types are the type of data stored in a C program. Data types are used while
defining a variable or functions in C. The compiler needs to understand the type of
predefined data it will encounter in the program. A data type is an attribute that tells
a computer how to interpret the value.

2 Importance 😎
Using appropriate data types makes the program more readable, scalable and
relevant to the problem being solved.

3 Usage 🤓
Data types help to define the memory size required for variables and functions.
Types of Data Types
Integer Floating Point Character
Used to represent integer Used to represent decimal Used to represent characters.
values. eg: int, short int, long values. eg: float, double etc. eg: char.
int etc.

Union Array Pointer


Used to store different types of Used to store a collection of Used to store the memory
data in the same memory elements of the same type. eg: address of another variable. eg:
location. eg: union. int[], char[], etc. int*, char*, etc.

Enum

Used to define a set of named values. eg: enum.

Structure

Used to define a custom data type that can hold multiple values of different types. eg: struct.
Characteristics of Data Types
1 Scope 🎯
Determines the range of values that the data type can store and operate
on. eg: 8-bit, 16-bit, 32-bit etc.

2 Precision 💻
Determines the accuracy level of the data type. eg: float has better
precision than integer.

3 Signage 🔢
Specifies if a data type can store negative values or not.
Size of Data Types
Unsigned Char 🔍 Int 👓
1 byte, 0 to 255. 2 or 4 bytes, -32768 to 32767 or -2,147,483,648
to 2,147,483,647.

Float 🔍 Double 📊
4 bytes, 1.2E-38 to 3.4E+38. 8 bytes, 2.3E-308 to 1.7E+308.

Array Pointer
The size of an array depends on the number of Pointers themselves occupy 4 or 8 bytes of
elements and the size of each element. For memory depending on the system
example, an int array of 5 elements will occupy architecture. The size of the data they point to
4 bytes * 5 = 20 bytes of memory. depends on the data type.

Structure Union
The size of a structure is the sum of the sizes The size of a union is equal to the size of its
of its members. For example, if a structure has largest member. For example, if a union has an
an int member and a float member, it will int member and a float member, it will occupy
occupy 4 bytes for the int and 4 bytes for the 4 bytes since int and float are both 4 bytes.
float, totaling 8 bytes.

Enum
The size of an enum is implementation-defined. It can vary depending on the number of enum
constants and the underlying data type used by the compiler.
Uses of Data Types

🔢 📝
Optimizing Performing Manipulating

📏
Memory Usage Calculations Text
Using the correct data types is Data types can be used to
Choosing appropriate data essential for performing manipulate and process text
types can help optimize accurate calculations and data efficiently, such as
memory usage by reducing preventing overflow/underflow reading from and writing to
the memory footprint of the issues. files.
program.
Examples of Data Types in C

int float char


Used for integers. Example: int Used for decimal values. Used for individual characters.
age = 24; Example: float distance = 10.5; Example: char grade = 'A';
Thank You!

You might also like