Lecture No: 14 & 15
Data Types in ‘C’
&
Types of Data Types
1
Data Types
• Data types are used to declare variables before
using them.
• Two basic uses of data types are:
1. It tells the compiler what the variable name is.
2. It specifies what type of data variable will hold
and the set of operations that can be performed
on this data.
2
Data Types (Contd.)
• A light switch can be considered as a data type. It
has a set of two values as on and off and two
operations as turn on and turn off.
• For Example: int x;
• Here int is the data type of variable x. It defines
that only integer values can be stored in x and
when an operation is applied on x with integer
value, result would always be integer.
3
Types of Data Types
• C supports three classes of data types-
1. Primary (Fundamental) data types
e.g. int, float, char etc
2. User defined data types
e.g. structure, union, typedef, enum etc
3. Derived data types
e.g. Arrays, functions, pointers etc
4
Primary/ Fundamental Data Types
5
Integer Data Types
6
Floating point Data Types
7
Character Data Types
8
Derived Data Types
• Derived data types are basically the extended
version of fundamental data types.
• Derived data types don't create a new data type
but, instead they add some functionality to the
fundamental data types.
• Examples are Array, Function, Pointers etc.
9
User-Defined Data Types
• Data types which are defined by the user before
using them for declaration of variables to store
the data are called as user defined data types.
• It is not possible to build a whole software that
works only with integers, floating values, and
characters. At times we need some complex data
types that can hold complex data.
• Examples are Structure, union, type definition
and enumerated data types.
10