SlideShare a Scribd company logo
1 of 8
STRUCTU
RES
Definition
 To represent a collection of data items of different
types using a single name.
general format of a structure
struct tag_name
{
data_type member1;
data_type member2;
.................
}
To declare a structure variable
 The keyword struct.
 The structure tag name.
 List of variable names separated by commas.
 A terminating semicolon.
For example :
struct book book1,book2;
 To accessing a structure members using the dot
operator(.)
For example
book1.price
Arrays of structures
 Declare an array of structures, each element of the array
representing a structure variable.
 For example
struct class student[10];
 Each element is defined to be the type struct class.
Consider the following declaration
struct class
{
int subject1;
int subject2;
};
Arrays within structures
 Arrays as structure members.
 We can use single-dimensional or multi-dimensional
arrays of type int or float.
For example
struct marks
{
int number;
float subject[3];
}student;
Structures and functions
 Passing of structure values as arguments to
functions.
General definition
data_type function_name(struct str_name
str_var_name)
{
..............
return(expression);
}
Function calling
There are three methods by which the values of a
structure can be transferred from function
 The first method is to pass each member of the
structure as an actual argument of the function call.
 The second method involves passing of a copy of
the entire structure to the called function.
 The third approach employs a concept called
pointers to pass the structure as an argument.
THANK YOU

More Related Content

What's hot

Chapter 13.1.9
Chapter 13.1.9Chapter 13.1.9
Chapter 13.1.9
patcha535
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
eShikshak
 

What's hot (20)

#Jai c presentation
#Jai c presentation#Jai c presentation
#Jai c presentation
 
Structure in C
Structure in CStructure in C
Structure in C
 
Structure c
Structure cStructure c
Structure c
 
Structure in c
Structure in cStructure in c
Structure in c
 
Chapter 13.1.9
Chapter 13.1.9Chapter 13.1.9
Chapter 13.1.9
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
 
Structures
StructuresStructures
Structures
 
When to use a structure vs classes in c++
When to use a structure vs classes in c++When to use a structure vs classes in c++
When to use a structure vs classes in c++
 
Lk module4 structures
Lk module4 structuresLk module4 structures
Lk module4 structures
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppt
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
 
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
 
oop Lecture 1
oop Lecture 1oop Lecture 1
oop Lecture 1
 
Introduction linked list
Introduction linked listIntroduction linked list
Introduction linked list
 
CP01.pptx
CP01.pptxCP01.pptx
CP01.pptx
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Structure & Union in C++
Structure & Union in C++Structure & Union in C++
Structure & Union in C++
 
Structures
StructuresStructures
Structures
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 

Similar to Structures in c programming

Unit4 (2)
Unit4 (2)Unit4 (2)
Unit4 (2)
mrecedu
 
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
 

Similar to Structures in c programming (20)

structure and union1.pdf
structure and union1.pdfstructure and union1.pdf
structure and union1.pdf
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
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
 
Definition, Declaration of Structures in C.pptx
Definition, Declaration of Structures in C.pptxDefinition, Declaration of Structures in C.pptx
Definition, Declaration of Structures in C.pptx
 
Chap 10(structure and unions)
Chap 10(structure and unions)Chap 10(structure and unions)
Chap 10(structure and unions)
 
Structure and Typedef
Structure and TypedefStructure and Typedef
Structure and Typedef
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
Structure.pptx
Structure.pptxStructure.pptx
Structure.pptx
 
Chapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdfChapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdf
 
Unit-V.pptx
Unit-V.pptxUnit-V.pptx
Unit-V.pptx
 
Programming in C session 3
Programming in C session 3Programming in C session 3
Programming in C session 3
 
Unit4 (2)
Unit4 (2)Unit4 (2)
Unit4 (2)
 
Unit 4 qba
Unit 4 qbaUnit 4 qba
Unit 4 qba
 
Structure In C
Structure In CStructure In C
Structure 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++
2 lesson 2 object oriented programming in c++
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
DS_PPT.pptx
DS_PPT.pptxDS_PPT.pptx
DS_PPT.pptx
 
Structure & union
Structure & unionStructure & union
Structure & union
 

More from Kousalya M (6)

Function template
Function templateFunction template
Function template
 
Class template
Class templateClass template
Class template
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Binary search tree deletion
Binary search tree deletionBinary search tree deletion
Binary search tree deletion
 
Red black trees and their properties
Red black trees and their propertiesRed black trees and their properties
Red black trees and their properties
 
Red black tree insertion
Red black tree insertionRed black tree insertion
Red black tree insertion
 

Recently uploaded

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
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
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.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
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
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
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.
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Structures in c programming

  • 2. Definition  To represent a collection of data items of different types using a single name. general format of a structure struct tag_name { data_type member1; data_type member2; ................. }
  • 3. To declare a structure variable  The keyword struct.  The structure tag name.  List of variable names separated by commas.  A terminating semicolon. For example : struct book book1,book2;  To accessing a structure members using the dot operator(.) For example book1.price
  • 4. Arrays of structures  Declare an array of structures, each element of the array representing a structure variable.  For example struct class student[10];  Each element is defined to be the type struct class. Consider the following declaration struct class { int subject1; int subject2; };
  • 5. Arrays within structures  Arrays as structure members.  We can use single-dimensional or multi-dimensional arrays of type int or float. For example struct marks { int number; float subject[3]; }student;
  • 6. Structures and functions  Passing of structure values as arguments to functions. General definition data_type function_name(struct str_name str_var_name) { .............. return(expression); } Function calling
  • 7. There are three methods by which the values of a structure can be transferred from function  The first method is to pass each member of the structure as an actual argument of the function call.  The second method involves passing of a copy of the entire structure to the called function.  The third approach employs a concept called pointers to pass the structure as an argument.