SlideShare a Scribd company logo
1 of 23
Data Type
Data Type
• A data type defines a set of values that a
variable can store along with a set of
operations that can be performed on that
variable.
• Common data types are integer, character,
and real.
Data Type
• Data Types
Data Type
Data Type
• Basic Data type(Primary, fundamental)
• Integers, Character and Floating point
Primary Data type

Integer
Singed type
Unsigned type
int
unsigned int
short int
unsigned short int
long int
unsigned long int

Character
Signed char
Unsigned char

float

Floating Point
double long double
Data Type
• Basic Data type(Primary, fundamental)
• Integers

• Signed and unsigned types

Integer
Singed type
Unsigned type
int
unsigned int
short int
unsigned short int
long int
unsigned long int

• Signed– can store + and –ve integers
• Unsigned– can store only +ve integers
Data Type
• Basic Data type(Primary, fundamental)
• Signed type integers
• int :- integers are whole numbers, capable to
storing numeric value without decimal places.
• any number in the range -32768 to 32767
• It occupies 2 bytes of memory
• Long int :- required 4 bytes of memory.
• Value range from -2147483648 to 2147483647
• Long int variable can declare
• long int a,b; or long a;
Data Type
• Basic Data type(Primary, fundamental)
• Signed type integers
• Short integers :- need less space in memory (same
as int)
• Short int variable can delare
• short int a; or int a;( both are same)
Data Type
• Basic Data type(Primary, fundamental)
• Unsigned integers
• unsigned integers :- some time if we know in advanced,
the value stored in an integer variable is always be +ve.
• Such situations we can declared the variable as
unsigned int
• The range permissible integer value will shift from 0 to
65535 ie double the size of int
• Unsigned integer variable can declare
• unsigned int a; or unsigned a;( both are same)
Data Type
• Basic Data type(Primary, fundamental)
•
•
•
•

Unsigned integers
unsigned short integers :- same as unsigned int
unsigned long integers :Range 0 to 42949672954 (double size of long int)

• Unsigned long integer variable can declare
• unsigned long int a;
Data Type
• Basic Data type(Primary, fundamental)
• Characters

•
•
•
•

•
•
•
•

Character
Signed and unsigned types
Signed char
Both occupy 1 byte of memory
Unsigned char
But having different range
Signed char is same as ordinary char and has range 128 to 127
Unsigned char range from 0 to 255
Example
cnsigned char a;
char a;
Data Type
• Basic Data type(Primary, fundamental)
• Floating point

•
•
•
•
•
•

float

Floating Point
double long double

A float variable occupy 4 bytes of memory
Range from 3.4E-38 to 3.4E+38
Double occupy 8 bytes of memory
Range from 1.7E-308 to 1.7E+308
Long double occupy 10 bytes of memory
Range from 3.4E-4932 to 3.4E+4932
Data Type
Type
char
unsigned char
int
unsigned int
short int
long int
unsigned long int
float
double
long double

size (bytes)
1
1
2
2
2
4
4
4
8
10

Range
127 to -128
0 to 255
32768 to -32767
0 to 65535
32768 to -32767
2147483648 to - 2147483647
0 to 4294967295
3.4E-38 to 3.4E+38
1.7E-308 to 1.7E+308
3.4E-4932 to 3.4E+4932
Data Type
•
•
•
•
•

User Defined Data type

User Defined Data Type
Type Definition
Enumerated datatype
Structure
Union

Type Definition
Enumerated datatype
Structure
Union
Data Type
• User Defined Data Type
• Type Definition
• Allows user to define an identifier that would
represent an existing data type
• This identifier can later used to declared
variables
typedef type identifier
• syntax:-• Eg: typedef int integet;
• integer a;
Data Type
• User Defined Data Type
• Enumerated
• Allows user to declare variables can have one
value enclosed within braces.
• Way of attaching name to numbers
• syntax:-- enum identifier {value1, value2, …..};
• Eg: enum sex{male,female};
• Then value of male=0 and female=1
Data Type
• User Defined Data Type
• Structure

• A structure is a collection of one or more variables, possibly of
different types, grouped together under a single name
A structure is defined by the keyword struct followed by a
set of variables enclosed in braces.
Consider the following structure to represent a person’s details.
struct Personnel {
char name[100];
int age;
double height;
};
The variables name, age and height are called members of the
structure type Personnel.
Data Type
• User Defined Data Type
• Structure

There are two ways to define variables of a particular structure
type.
1. Declare them at the structure definition.
struct Personnel {
char name[100];
int age;
double height;
} p1, p2, p3; /* Define 3 variables */

2. Define the variables at some point after the structure
definition.
struct Personnel p1, p2, p3; /* Define 3 variables */
Data Type
• User Defined Data Type
• Union

• A union is a collection of one or more variables, possibly of
different types, grouped together under a single name
A union is defined by the keyword union followed by
a set of variables enclosed in braces.
Consider the following union to represent a person’s details.
union Personnel {
char name[100];
int age;
double height;
};
The variables name, age and height are called members
of the union type Personnel.
Data Type
• User Defined Data Type
• union

There are two ways to define variables of a particular union
type.
1. Declare them at the union definition.
union Personnel {
char name[100];
int age;
double height;
} p1, p2, p3; /* Define 3 variables */

2. Define the variables at some point after the union
definition.

union Personnel p1, p2, p3; /* Define 3 variables */
Data Type
•
•
•
•
•

Derived datatype
Array…
Functions…
Pointers…
Reference…

Derived datatype
Array
Function
Pointers

Reference
Data Type
• Empty data type
• void
Escape Sequence
Escape
Sequence
a
b
f
n
r
t
v

”
o
x
O

Effect
Beep sound
Backspace
Formfeed (for printing)
New line
Carriage return
Tab
Vertical tab
Backslash
“ sign
Octal decimal
Hexadecimal
NULL

Escape sequence is used in the printf() function to do something to
the output.

More Related Content

What's hot

Data types in C language
Data types in C languageData types in C language
Data types in C language
kashyap399
 

What's hot (20)

concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
User Defined Functions
User Defined FunctionsUser Defined Functions
User Defined Functions
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
C++ string
C++ stringC++ string
C++ string
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Data types in C
Data types in CData types in C
Data types in C
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
 
Enums in c
Enums in cEnums in c
Enums in c
 
Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structure
 
Loops c++
Loops c++Loops c++
Loops c++
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Array in c++
Array in c++Array in c++
Array in c++
 

Viewers also liked

Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statistics
akbhanj
 
Introduction To Statistics
Introduction To StatisticsIntroduction To Statistics
Introduction To Statistics
albertlaporte
 
Computer data type and Terminologies
Computer data type and Terminologies Computer data type and Terminologies
Computer data type and Terminologies
glyvive
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statistics
madan kumar
 
Data types
Data typesData types
Data types
gavhays
 
zivotni ciklus organizacije
zivotni ciklus organizacijezivotni ciklus organizacije
zivotni ciklus organizacije
edita1990
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
Manisha Keim
 
Sampling designs
Sampling designsSampling designs
Sampling designs
Marni Bunda
 
GOOGLE ANALYTICS by Donny BU
GOOGLE ANALYTICS by Donny BUGOOGLE ANALYTICS by Donny BU
GOOGLE ANALYTICS by Donny BU
Akademi Berbagi
 
Ewil survey results
Ewil survey resultsEwil survey results
Ewil survey results
Imede
 

Viewers also liked (20)

Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statistics
 
Introduction To Statistics
Introduction To StatisticsIntroduction To Statistics
Introduction To Statistics
 
Computer data type and Terminologies
Computer data type and Terminologies Computer data type and Terminologies
Computer data type and Terminologies
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statistics
 
Introduction to statistics...ppt rahul
Introduction to statistics...ppt rahulIntroduction to statistics...ppt rahul
Introduction to statistics...ppt rahul
 
Introduction to Elementary statistics
Introduction to Elementary statisticsIntroduction to Elementary statistics
Introduction to Elementary statistics
 
RESEARCH METHOD - SAMPLING
RESEARCH METHOD - SAMPLINGRESEARCH METHOD - SAMPLING
RESEARCH METHOD - SAMPLING
 
Data types
Data typesData types
Data types
 
zivotni ciklus organizacije
zivotni ciklus organizacijezivotni ciklus organizacije
zivotni ciklus organizacije
 
Data type in c
Data type in cData type in c
Data type in c
 
Esquemas
EsquemasEsquemas
Esquemas
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture Notes
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
Pwan homes
Pwan homesPwan homes
Pwan homes
 
Sampling designs
Sampling designsSampling designs
Sampling designs
 
Applied Math 40S March 12, 2008
Applied Math 40S March 12, 2008Applied Math 40S March 12, 2008
Applied Math 40S March 12, 2008
 
GOOGLE ANALYTICS by Donny BU
GOOGLE ANALYTICS by Donny BUGOOGLE ANALYTICS by Donny BU
GOOGLE ANALYTICS by Donny BU
 
Data What Type Of Data Do You Have V2.1
Data   What Type Of Data Do You Have V2.1Data   What Type Of Data Do You Have V2.1
Data What Type Of Data Do You Have V2.1
 
Ewil survey results
Ewil survey resultsEwil survey results
Ewil survey results
 

Similar to Data type

cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
YRABHI
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
PRASANYA K
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
atifmugheesv
 

Similar to Data type (20)

Data types03
Data types03Data types03
Data types03
 
Data Types in C language
Data Types in C languageData Types in C language
Data Types in C language
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 
Variable
VariableVariable
Variable
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
Data types IN JAVA
Data types IN JAVAData types IN JAVA
Data types IN JAVA
 
Data Handling
Data HandlingData Handling
Data Handling
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.net
 
Java basic datatypes
Java basic datatypesJava basic datatypes
Java basic datatypes
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
 
enum_namespace.ppt
enum_namespace.pptenum_namespace.ppt
enum_namespace.ppt
 
Datatypes
DatatypesDatatypes
Datatypes
 
Data types in C
Data types in CData types in C
Data types in C
 
Variables&DataTypes.pptx
Variables&DataTypes.pptxVariables&DataTypes.pptx
Variables&DataTypes.pptx
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variables
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptx
 

More from Frijo Francis

More from Frijo Francis (11)

Type conversion
Type conversionType conversion
Type conversion
 
Structure
StructureStructure
Structure
 
Recursion prog
Recursion progRecursion prog
Recursion prog
 
Recursion prog (1)
Recursion prog (1)Recursion prog (1)
Recursion prog (1)
 
Pointers
PointersPointers
Pointers
 
C programming language
C programming languageC programming language
C programming language
 
6 enumerated, typedef
6 enumerated, typedef6 enumerated, typedef
6 enumerated, typedef
 
5bit field
5bit field5bit field
5bit field
 
4 dynamic memory allocation
4 dynamic memory allocation4 dynamic memory allocation
4 dynamic memory allocation
 
Union
UnionUnion
Union
 
1file handling
1file handling1file handling
1file handling
 

Recently uploaded

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Data type

  • 2. Data Type • A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. • Common data types are integer, character, and real.
  • 5. Data Type • Basic Data type(Primary, fundamental) • Integers, Character and Floating point Primary Data type Integer Singed type Unsigned type int unsigned int short int unsigned short int long int unsigned long int Character Signed char Unsigned char float Floating Point double long double
  • 6. Data Type • Basic Data type(Primary, fundamental) • Integers • Signed and unsigned types Integer Singed type Unsigned type int unsigned int short int unsigned short int long int unsigned long int • Signed– can store + and –ve integers • Unsigned– can store only +ve integers
  • 7. Data Type • Basic Data type(Primary, fundamental) • Signed type integers • int :- integers are whole numbers, capable to storing numeric value without decimal places. • any number in the range -32768 to 32767 • It occupies 2 bytes of memory • Long int :- required 4 bytes of memory. • Value range from -2147483648 to 2147483647 • Long int variable can declare • long int a,b; or long a;
  • 8. Data Type • Basic Data type(Primary, fundamental) • Signed type integers • Short integers :- need less space in memory (same as int) • Short int variable can delare • short int a; or int a;( both are same)
  • 9. Data Type • Basic Data type(Primary, fundamental) • Unsigned integers • unsigned integers :- some time if we know in advanced, the value stored in an integer variable is always be +ve. • Such situations we can declared the variable as unsigned int • The range permissible integer value will shift from 0 to 65535 ie double the size of int • Unsigned integer variable can declare • unsigned int a; or unsigned a;( both are same)
  • 10. Data Type • Basic Data type(Primary, fundamental) • • • • Unsigned integers unsigned short integers :- same as unsigned int unsigned long integers :Range 0 to 42949672954 (double size of long int) • Unsigned long integer variable can declare • unsigned long int a;
  • 11. Data Type • Basic Data type(Primary, fundamental) • Characters • • • • • • • • Character Signed and unsigned types Signed char Both occupy 1 byte of memory Unsigned char But having different range Signed char is same as ordinary char and has range 128 to 127 Unsigned char range from 0 to 255 Example cnsigned char a; char a;
  • 12. Data Type • Basic Data type(Primary, fundamental) • Floating point • • • • • • float Floating Point double long double A float variable occupy 4 bytes of memory Range from 3.4E-38 to 3.4E+38 Double occupy 8 bytes of memory Range from 1.7E-308 to 1.7E+308 Long double occupy 10 bytes of memory Range from 3.4E-4932 to 3.4E+4932
  • 13. Data Type Type char unsigned char int unsigned int short int long int unsigned long int float double long double size (bytes) 1 1 2 2 2 4 4 4 8 10 Range 127 to -128 0 to 255 32768 to -32767 0 to 65535 32768 to -32767 2147483648 to - 2147483647 0 to 4294967295 3.4E-38 to 3.4E+38 1.7E-308 to 1.7E+308 3.4E-4932 to 3.4E+4932
  • 14. Data Type • • • • • User Defined Data type User Defined Data Type Type Definition Enumerated datatype Structure Union Type Definition Enumerated datatype Structure Union
  • 15. Data Type • User Defined Data Type • Type Definition • Allows user to define an identifier that would represent an existing data type • This identifier can later used to declared variables typedef type identifier • syntax:-• Eg: typedef int integet; • integer a;
  • 16. Data Type • User Defined Data Type • Enumerated • Allows user to declare variables can have one value enclosed within braces. • Way of attaching name to numbers • syntax:-- enum identifier {value1, value2, …..}; • Eg: enum sex{male,female}; • Then value of male=0 and female=1
  • 17. Data Type • User Defined Data Type • Structure • A structure is a collection of one or more variables, possibly of different types, grouped together under a single name A structure is defined by the keyword struct followed by a set of variables enclosed in braces. Consider the following structure to represent a person’s details. struct Personnel { char name[100]; int age; double height; }; The variables name, age and height are called members of the structure type Personnel.
  • 18. Data Type • User Defined Data Type • Structure There are two ways to define variables of a particular structure type. 1. Declare them at the structure definition. struct Personnel { char name[100]; int age; double height; } p1, p2, p3; /* Define 3 variables */ 2. Define the variables at some point after the structure definition. struct Personnel p1, p2, p3; /* Define 3 variables */
  • 19. Data Type • User Defined Data Type • Union • A union is a collection of one or more variables, possibly of different types, grouped together under a single name A union is defined by the keyword union followed by a set of variables enclosed in braces. Consider the following union to represent a person’s details. union Personnel { char name[100]; int age; double height; }; The variables name, age and height are called members of the union type Personnel.
  • 20. Data Type • User Defined Data Type • union There are two ways to define variables of a particular union type. 1. Declare them at the union definition. union Personnel { char name[100]; int age; double height; } p1, p2, p3; /* Define 3 variables */ 2. Define the variables at some point after the union definition. union Personnel p1, p2, p3; /* Define 3 variables */
  • 22. Data Type • Empty data type • void
  • 23. Escape Sequence Escape Sequence a b f n r t v ” o x O Effect Beep sound Backspace Formfeed (for printing) New line Carriage return Tab Vertical tab Backslash “ sign Octal decimal Hexadecimal NULL Escape sequence is used in the printf() function to do something to the output.