SlideShare a Scribd company logo
1 of 16
Download to read offline
STRUCTURES AND UNIONS
REFERENCE: PROGRAMMING IN C BY BALAGURUSWAMY
MRS. SOWMYA JYOTHI, SDMCBM, MANGALORE
STRUCTURES
Arrays are used to store large set of data and manipulate them
but the disadvantage is that all the elements stored in an array
are to be of the same data type. If we need to use a collection of
different data type items it is not possible using an array.
When we require using a collection of different data items of
different data types we can use a structure.
Structure is a method of packing data of different types.
A structure is a convenient method of handling a group of
related data items of different data types.
Structure definition:
General format:
struct tag_name
{
datatype member1;
datatype member2;
…
…
};
A structure is usually defines before
main along with macro definitions.
In such cases the structure assumes
global status and all the functions
can access the structure.
Example:
struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
};
The keyword struct declares a structure
to holds the details of four fields namely
title, author pages and price. These are
members of the structures.
Each member may belong to different or
same data type. The tag name can be
used to define objects that have the tag
names structure.
The structure we just declared is not a
variable by itself but a template for the
structure.
We can declare structure variables using the tag
name any where in the program.
For example the statement,
For example: struct lib_books book1,book2,book3;
declares book1,book2,book3 as variables of type
struct lib_books each declaration has four elements
of the structure lib_books.
struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
};
struct lib_books, book1, book2, book3;
Structures do not occupy any memory until it is
associated with the structure variable such as book1.
The template is terminated with a semicolon.
While the entire declaration is considered as a
statement, each member is declared independently for
its name and type in a separate statement inside the
template.
The tag name such as lib_books can be used to declare
structure variables of its data type later in the program.
We can also combine both
template declaration and
variables declaration in one
statement.
struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
} book1,book2,book3;
Giving values to members:
The members themselves are not variables they should be linked to
structure variables in order to make them meaningful members.
The link between a member and a variable is established using the
member operator ‘.’ known as dot operator or period operator.
For example: Book1.price
scanf("%s",Book1.file);
scanf("%d",& Book1.pages);
strcpy(book1.title,"basic");
strcpy(book1.author,"Balagurusamy");
book1.pages=250;
book1.price=28.50;
Initializing structure:
Like other data type we can initialize structure when we
declare them.
As for initialization goes structure obeys the same set of rules
as arrays.
We initialize the fields of a structure by the following
structure declaration with a list containing values for each
fields as with arrays these values must be evaluate at compile
time.
struct student
{
int id_no;
char name[20];
char address[20];
char combination[3];
int age;
}newstudent;
struct student newstudent
{
12345,
“kapildev”
“pes college”;
“cse”;
19;
};
This initializes the id_no field to 12345, the name field to "kapildev", the
address field to "pes college" the field combination to "cse" and the age
field to 19.
UNION
A union is a special data type available in C that allows storing
different data types in the same memory location. You can define
a union with many members, but only one member can contain a
value at any given time. Unions provide an efficient way of using
the same memory location for multiple purposes.
Defining a Union:
To define a union, you must use the union statement in the same
way as you did while defining a structure. The union statement
defines a new data type with more than one member for your
program.
union [union name]
{
member definition;
member definition;
...
member definition;
};
union union_example
{
int integer;
float decimal;
char name[20];
};
The format of the union statement is as follows:
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf

More Related Content

What's hot

User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in CHarendra Singh
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiSowmya Jyothi
 
C Pointers
C PointersC Pointers
C Pointersomukhtar
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2MOHIT TOMAR
 
Pointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanPointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanMohammadSalman129
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C ProgrammingDevoAjit Gupta
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of ConstructorsDhrumil Panchal
 
Structures in c language
Structures in c languageStructures in c language
Structures in c languagetanmaymodi4
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiSowmyaJyothi3
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocationViji B
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in CArpana shree
 
Union In language C
Union In language CUnion In language C
Union In language CRavi Singh
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classesasadsardar
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c languagetanmaymodi4
 
Storage class in c
Storage class in cStorage class in c
Storage class in ckash95
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cSowmya Jyothi
 

What's hot (20)

User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
C Pointers
C PointersC Pointers
C Pointers
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
 
Pointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanPointers in c - Mohammad Salman
Pointers in c - Mohammad Salman
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
String in c
String in cString in c
String in c
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in C
 
Union In language C
Union In language CUnion In language C
Union In language C
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
 
Function in C
Function in CFunction in C
Function in C
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 

Similar to STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf

Lk module4 structures
Lk module4 structuresLk module4 structures
Lk module4 structuresKrishna Nanda
 
Structure prespentation
Structure prespentation Structure prespentation
Structure prespentation ashu awais
 
C UNIT-4 PREPARED BY M V BRAHMANANDA RE
C UNIT-4 PREPARED BY M V BRAHMANANDA REC UNIT-4 PREPARED BY M V BRAHMANANDA RE
C UNIT-4 PREPARED BY M V BRAHMANANDA RERajeshkumar Reddy
 
CPU : Structures And Unions
CPU : Structures And UnionsCPU : Structures And Unions
CPU : Structures And UnionsDhrumil Patel
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and UnionsDhrumil Patel
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structureshaibal sharif
 
2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++Jeff TUYISHIME
 
Structures in c language
Structures in c languageStructures in c language
Structures in c languageTanmay Modi
 
structure and union1.pdf
structure and union1.pdfstructure and union1.pdf
structure and union1.pdfHMCollegeInfo
 
Chapter 13.1.9
Chapter 13.1.9Chapter 13.1.9
Chapter 13.1.9patcha535
 
Structures in c++
Structures in c++Structures in c++
Structures in c++Swarup Boro
 
Introduction of structure (2)
Introduction of structure (2)Introduction of structure (2)
Introduction of structure (2)Jatin Sharma
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 

Similar to STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf (20)

Lk module4 structures
Lk module4 structuresLk module4 structures
Lk module4 structures
 
Structure prespentation
Structure prespentation Structure prespentation
Structure prespentation
 
C UNIT-4 PREPARED BY M V BRAHMANANDA RE
C UNIT-4 PREPARED BY M V BRAHMANANDA REC UNIT-4 PREPARED BY M V BRAHMANANDA RE
C UNIT-4 PREPARED BY M V BRAHMANANDA RE
 
Programming in C
Programming in CProgramming in C
Programming in C
 
CPU : Structures And Unions
CPU : Structures And UnionsCPU : Structures And Unions
CPU : Structures And Unions
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structure
 
2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
structure and union1.pdf
structure and union1.pdfstructure and union1.pdf
structure and union1.pdf
 
Chapter 13.1.9
Chapter 13.1.9Chapter 13.1.9
Chapter 13.1.9
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Unit 4 qba
Unit 4 qbaUnit 4 qba
Unit 4 qba
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
Lecture 19 - Struct and Union
Lecture 19 - Struct and UnionLecture 19 - Struct and Union
Lecture 19 - Struct and Union
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
Introduction of structure (2)
Introduction of structure (2)Introduction of structure (2)
Introduction of structure (2)
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 

Recently uploaded

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf

  • 1. STRUCTURES AND UNIONS REFERENCE: PROGRAMMING IN C BY BALAGURUSWAMY MRS. SOWMYA JYOTHI, SDMCBM, MANGALORE
  • 2. STRUCTURES Arrays are used to store large set of data and manipulate them but the disadvantage is that all the elements stored in an array are to be of the same data type. If we need to use a collection of different data type items it is not possible using an array. When we require using a collection of different data items of different data types we can use a structure. Structure is a method of packing data of different types. A structure is a convenient method of handling a group of related data items of different data types.
  • 3. Structure definition: General format: struct tag_name { datatype member1; datatype member2; … … }; A structure is usually defines before main along with macro definitions. In such cases the structure assumes global status and all the functions can access the structure.
  • 4. Example: struct lib_books { char title[20]; char author[15]; int pages; float price; }; The keyword struct declares a structure to holds the details of four fields namely title, author pages and price. These are members of the structures. Each member may belong to different or same data type. The tag name can be used to define objects that have the tag names structure. The structure we just declared is not a variable by itself but a template for the structure.
  • 5. We can declare structure variables using the tag name any where in the program. For example the statement, For example: struct lib_books book1,book2,book3; declares book1,book2,book3 as variables of type struct lib_books each declaration has four elements of the structure lib_books.
  • 6. struct lib_books { char title[20]; char author[15]; int pages; float price; }; struct lib_books, book1, book2, book3; Structures do not occupy any memory until it is associated with the structure variable such as book1. The template is terminated with a semicolon. While the entire declaration is considered as a statement, each member is declared independently for its name and type in a separate statement inside the template. The tag name such as lib_books can be used to declare structure variables of its data type later in the program.
  • 7. We can also combine both template declaration and variables declaration in one statement. struct lib_books { char title[20]; char author[15]; int pages; float price; } book1,book2,book3;
  • 8. Giving values to members: The members themselves are not variables they should be linked to structure variables in order to make them meaningful members. The link between a member and a variable is established using the member operator ‘.’ known as dot operator or period operator. For example: Book1.price scanf("%s",Book1.file); scanf("%d",& Book1.pages); strcpy(book1.title,"basic"); strcpy(book1.author,"Balagurusamy"); book1.pages=250; book1.price=28.50;
  • 9. Initializing structure: Like other data type we can initialize structure when we declare them. As for initialization goes structure obeys the same set of rules as arrays. We initialize the fields of a structure by the following structure declaration with a list containing values for each fields as with arrays these values must be evaluate at compile time.
  • 10. struct student { int id_no; char name[20]; char address[20]; char combination[3]; int age; }newstudent; struct student newstudent { 12345, “kapildev” “pes college”; “cse”; 19; }; This initializes the id_no field to 12345, the name field to "kapildev", the address field to "pes college" the field combination to "cse" and the age field to 19.
  • 11. UNION A union is a special data type available in C that allows storing different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple purposes. Defining a Union: To define a union, you must use the union statement in the same way as you did while defining a structure. The union statement defines a new data type with more than one member for your program.
  • 12. union [union name] { member definition; member definition; ... member definition; }; union union_example { int integer; float decimal; char name[20]; }; The format of the union statement is as follows: