SlideShare a Scribd company logo
Definition of structures
• A structure is a collection of logically related
elements having a single name.
Syntax:
struct tag_name
{
type1 member1;
type2 member2;
……………
} empty or variable;
struct student
{
char name[10];
Int roll_number;
} s1;
Initialization of structures
• Example
struct student
{
char name[5];
int roll_number;
} s1={“ravi”,10};
struct student
{
char name[5];
int roll_number;
};
struct student s1= {“ravi”,10};
Accessing structures
• Structures use a dot (.) operator to refer
to its elements also known as period
operator.
• Syntax:
structure_variablename.structure_membername
Example for accessing structures
struct student
{
char name[5];
int roll_number;
};
struct student s1= {“ravi”,10};
Accessing members using variables as:
s1.name refers to string “ravi”
s1.roll_number refers to roll_number 10
Definition of union
• Union is a collection of variables referred
under a single name.
• Syntax and declaration of union is similar to a
structure but its functionality is different.
• In structures, each member has its own
storage whereas all members of union use
the same location.
Syntax and example
union tag_name
{
type1 member1;
type2 member2;
……………
} empty or variable;
union u
{
char c;
int i;
} a;
Accessing members
a.c
a.i
Definition
• An enumerated data type is a user defined data
type which includes descriptive names also called
enumerators.
• Syntax
enum type_name
{
member1;
member2;
……………
} empty or variable;
enum color
{
RED;
BLUE;
GREEN;
} c;
Definition
• A pointer is a variable that points to a memory
location in which data is stored.
• Example: if v is a variable stored in memory,
then to access the location of v, we define
another variable pv.
pv= &v;
Address of v Value of v
pv v
• In order to access the data of variable v, then
*pv is used, where * is unary operator, called
indirection operator.
• For example: if we take another variable u,
then to access the value we use:
pv= &v;
u= *pv;

More Related Content

What's hot

Nested class in java
Nested class in javaNested class in java
Nested class in java
ChiradipBhattacharya
 
Variables in python
Variables in pythonVariables in python
Variables in python
Jaya Kumari
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
Michael Heron
 
Oops
OopsOops
[OOP - Lec 08] Encapsulation (Information Hiding)
[OOP - Lec 08] Encapsulation (Information Hiding)[OOP - Lec 08] Encapsulation (Information Hiding)
[OOP - Lec 08] Encapsulation (Information Hiding)
Muhammad Hammad Waseem
 
C# Basics
C# BasicsC# Basics
C# Basics
Binu Bhasuran
 
Road to code
Road to codeRoad to code
Road to code
Apoorvi Kapoor
 
Object as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasObject as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younas
Shahzad Younas
 
SPC Unit 5
SPC Unit 5SPC Unit 5
SPC Unit 5
SIMONTHOMAS S
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - Encapsulation
Michael Heron
 

What's hot (11)

Nested class in java
Nested class in javaNested class in java
Nested class in java
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
 
Oops
OopsOops
Oops
 
[OOP - Lec 08] Encapsulation (Information Hiding)
[OOP - Lec 08] Encapsulation (Information Hiding)[OOP - Lec 08] Encapsulation (Information Hiding)
[OOP - Lec 08] Encapsulation (Information Hiding)
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Road to code
Road to codeRoad to code
Road to code
 
Object as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasObject as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younas
 
SPC Unit 5
SPC Unit 5SPC Unit 5
SPC Unit 5
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - Encapsulation
 

Similar to structures in C and Union in C, enumerated datatype

User defined data types.pptx
User defined data types.pptxUser defined data types.pptx
User defined data types.pptx
Ananthi Palanisamy
 
Structures
StructuresStructures
Structures
selvapon
 
1. structure
1. structure1. structure
1. structure
hasan Mohammad
 
Structure in C
Structure in CStructure in C
Structure in C
Kamal Acharya
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
sangrampatil81
 
Fundamentals of Structure in C Programming
Fundamentals of Structure in C ProgrammingFundamentals of Structure in C Programming
Fundamentals of Structure in C Programming
Chandrakant Divate
 
Structure in C
Structure in CStructure in C
Structure in C
Fazle Rabbi Ador
 
Session 6
Session 6Session 6
358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7
sumitbardhan
 
Struct
StructStruct
Struct
Fahuda E
 
Structure In C
Structure In CStructure In C
Structure In C
yndaravind
 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
psaravanan1985
 
CP Handout#10
CP Handout#10CP Handout#10
CP Handout#10
trupti1976
 
CA2_CYS101_31184422012_Arvind-Shukla.pptx
CA2_CYS101_31184422012_Arvind-Shukla.pptxCA2_CYS101_31184422012_Arvind-Shukla.pptx
CA2_CYS101_31184422012_Arvind-Shukla.pptx
ArvindShukla81
 
Engineering Computers - L29-Structures.pptx
Engineering Computers - L29-Structures.pptxEngineering Computers - L29-Structures.pptx
Engineering Computers - L29-Structures.pptx
happycocoman
 
Chap 10(structure and unions)
Chap 10(structure and unions)Chap 10(structure and unions)
Structure in C language
Structure in C languageStructure in C language
Structure in C language
CGC Technical campus,Mohali
 
Structure c
Structure cStructure c
Structure c
thirumalaikumar3
 
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Smit Shah
 
self_refrential_structures.pptx
self_refrential_structures.pptxself_refrential_structures.pptx
self_refrential_structures.pptx
AshishNayyar12
 

Similar to structures in C and Union in C, enumerated datatype (20)

User defined data types.pptx
User defined data types.pptxUser defined data types.pptx
User defined data types.pptx
 
Structures
StructuresStructures
Structures
 
1. structure
1. structure1. structure
1. structure
 
Structure in C
Structure in CStructure in C
Structure in C
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
 
Fundamentals of Structure in C Programming
Fundamentals of Structure in C ProgrammingFundamentals of Structure in C Programming
Fundamentals of Structure in C Programming
 
Structure in C
Structure in CStructure in C
Structure in C
 
Session 6
Session 6Session 6
Session 6
 
358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7
 
Struct
StructStruct
Struct
 
Structure In C
Structure In CStructure In C
Structure In C
 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
 
CP Handout#10
CP Handout#10CP Handout#10
CP Handout#10
 
CA2_CYS101_31184422012_Arvind-Shukla.pptx
CA2_CYS101_31184422012_Arvind-Shukla.pptxCA2_CYS101_31184422012_Arvind-Shukla.pptx
CA2_CYS101_31184422012_Arvind-Shukla.pptx
 
Engineering Computers - L29-Structures.pptx
Engineering Computers - L29-Structures.pptxEngineering Computers - L29-Structures.pptx
Engineering Computers - L29-Structures.pptx
 
Chap 10(structure and unions)
Chap 10(structure and unions)Chap 10(structure and unions)
Chap 10(structure and unions)
 
Structure in C language
Structure in C languageStructure in C language
Structure in C language
 
Structure c
Structure cStructure c
Structure c
 
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
 
self_refrential_structures.pptx
self_refrential_structures.pptxself_refrential_structures.pptx
self_refrential_structures.pptx
 

More from preetikapri1

Forces
ForcesForces
Forces
preetikapri1
 
software quality
software qualitysoftware quality
software quality
preetikapri1
 
UML model
UML model UML model
UML model
preetikapri1
 
Er diagrams
Er diagramsEr diagrams
Er diagrams
preetikapri1
 
Data flow diagram
Data flow diagramData flow diagram
Data flow diagram
preetikapri1
 
types of testing in software engineering
types of testing in software engineering types of testing in software engineering
types of testing in software engineering
preetikapri1
 
bit wise operators and I/O operations in C
bit wise operators and I/O operations in Cbit wise operators and I/O operations in C
bit wise operators and I/O operations in C
preetikapri1
 
Ms access
Ms access Ms access
Ms access
preetikapri1
 
Functions
FunctionsFunctions
Functions
preetikapri1
 
C programming
C programmingC programming
C programming
preetikapri1
 
C preprocesor
C preprocesorC preprocesor
C preprocesor
preetikapri1
 
Window object
Window objectWindow object
Window object
preetikapri1
 
DTD elements
DTD elementsDTD elements
DTD elements
preetikapri1
 
Html
HtmlHtml
Css font
Css fontCss font
Css font
preetikapri1
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applications
preetikapri1
 
architecture framework for ecommerce
architecture framework for ecommercearchitecture framework for ecommerce
architecture framework for ecommerce
preetikapri1
 
impact of ecommerce on traditional means
impact of ecommerce on traditional means impact of ecommerce on traditional means
impact of ecommerce on traditional means
preetikapri1
 
electronic data interchange
electronic data interchange electronic data interchange
electronic data interchange
preetikapri1
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applications
preetikapri1
 

More from preetikapri1 (20)

Forces
ForcesForces
Forces
 
software quality
software qualitysoftware quality
software quality
 
UML model
UML model UML model
UML model
 
Er diagrams
Er diagramsEr diagrams
Er diagrams
 
Data flow diagram
Data flow diagramData flow diagram
Data flow diagram
 
types of testing in software engineering
types of testing in software engineering types of testing in software engineering
types of testing in software engineering
 
bit wise operators and I/O operations in C
bit wise operators and I/O operations in Cbit wise operators and I/O operations in C
bit wise operators and I/O operations in C
 
Ms access
Ms access Ms access
Ms access
 
Functions
FunctionsFunctions
Functions
 
C programming
C programmingC programming
C programming
 
C preprocesor
C preprocesorC preprocesor
C preprocesor
 
Window object
Window objectWindow object
Window object
 
DTD elements
DTD elementsDTD elements
DTD elements
 
Html
HtmlHtml
Html
 
Css font
Css fontCss font
Css font
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applications
 
architecture framework for ecommerce
architecture framework for ecommercearchitecture framework for ecommerce
architecture framework for ecommerce
 
impact of ecommerce on traditional means
impact of ecommerce on traditional means impact of ecommerce on traditional means
impact of ecommerce on traditional means
 
electronic data interchange
electronic data interchange electronic data interchange
electronic data interchange
 
consumer oriented applications
consumer oriented applicationsconsumer oriented applications
consumer oriented applications
 

Recently uploaded

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
maazsz111
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 

Recently uploaded (20)

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 

structures in C and Union in C, enumerated datatype

  • 1.
  • 2. Definition of structures • A structure is a collection of logically related elements having a single name. Syntax: struct tag_name { type1 member1; type2 member2; …………… } empty or variable; struct student { char name[10]; Int roll_number; } s1;
  • 3. Initialization of structures • Example struct student { char name[5]; int roll_number; } s1={“ravi”,10}; struct student { char name[5]; int roll_number; }; struct student s1= {“ravi”,10};
  • 4. Accessing structures • Structures use a dot (.) operator to refer to its elements also known as period operator. • Syntax: structure_variablename.structure_membername
  • 5. Example for accessing structures struct student { char name[5]; int roll_number; }; struct student s1= {“ravi”,10}; Accessing members using variables as: s1.name refers to string “ravi” s1.roll_number refers to roll_number 10
  • 6.
  • 7. Definition of union • Union is a collection of variables referred under a single name. • Syntax and declaration of union is similar to a structure but its functionality is different. • In structures, each member has its own storage whereas all members of union use the same location.
  • 8. Syntax and example union tag_name { type1 member1; type2 member2; …………… } empty or variable; union u { char c; int i; } a; Accessing members a.c a.i
  • 9.
  • 10. Definition • An enumerated data type is a user defined data type which includes descriptive names also called enumerators. • Syntax enum type_name { member1; member2; …………… } empty or variable; enum color { RED; BLUE; GREEN; } c;
  • 11.
  • 12. Definition • A pointer is a variable that points to a memory location in which data is stored. • Example: if v is a variable stored in memory, then to access the location of v, we define another variable pv. pv= &v; Address of v Value of v pv v
  • 13. • In order to access the data of variable v, then *pv is used, where * is unary operator, called indirection operator. • For example: if we take another variable u, then to access the value we use: pv= &v; u= *pv;