SlideShare a Scribd company logo
1 of 20
CONTENTS :
 Introduction of structure
 Array of structure
 Nested structure
 Structure with pointer
Introduction -
In C/C++, struct keyword is used to define
a structure, a structure is the collection of
variables with a common name. Structure
variables are called fields. A structure is
heterogeneous in that it can be composed
of data of different types. Structure is an
user defined data type.
 Simple structure –
struct Structure_name{
datatype fieldname1;
datatype fieldname2;
………………………;
datatype fieldnamen;
};
The members of a structure are accessed with
the dot (.) operator.
syntax – structure_var_name.fieldname;
: st.rollno;
st.st_name;
st.per_marks;
 In contrast, array is homogeneous since it can
contain only data of the same type.
 Complex data structures can be formed by
defining arrays of structs.
syntax – struct structure_name array_name[i];
For Exa : struct student_type st[50];
Int main()
{
struct student st[50];
int I;
for(i=0;i<5;i++)
{
When a structure whose member also of a
structure type then such structure are called
Nested structure.
Nested are of two types –
1) Separate Structure
2) Embedded Structure
1) : We can create two
structures, but dependent
structure should be used inside the main
structure as a member.
struct date{
int dd;
int mm;
int yyyy;
}doj;
struct employee{
int id;
char name[20];
struct date doj;
}emp1;
2) Embedded Structure : In this structure,
we can define structure
within the structure also.
struct employee{
int id;
char name[20];
struct date{
int dd;
int mm;
int yyyy;
}doj;
}emp1;
Structure with Pointer -
 Pointer variable can point to the address of a structure
variable.
For Exa – struct dog{
char name[10];
char breed[10];
int age;
char colour[10];
}spike;
struct dog my_dog={“tyke”,”Bulldog”, 5, “White”};
struct dog *ptr_dog;
ptr_dog=&spike;
When we want to access member of the
structure through pointer, arrow (->)
operator is used.
For Exa –
ptr_dog->name;
ptr_dog->breed;
Or –
(*ptr_dog).name;
(*ptr_dog).breed;
 For Exa –
struct point{
int x;
int y;
}point;
int main()
{
Point P;
printf(“Enter the coordinates of point”);
input(&P);
output(&P);
}
void input(point *point_ptr)
{
scanf(“%d”,&(point_ptr->x));
scanf(“%d”,&(point_ptr->y));
}
void output(point p)
{
printf(“x coordinate=%d”,p.x);
printf(“y coordinate=%d”,p.y);
}
#Jai c presentation

More Related Content

What's hot

What's hot (20)

Structure c
Structure cStructure c
Structure c
 
Structures
StructuresStructures
Structures
 
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
 
Structure in C
Structure in CStructure in C
Structure in C
 
Programming in C session 3
Programming in C session 3Programming in C session 3
Programming in C session 3
 
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...
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 
Unit4 C
Unit4 C Unit4 C
Unit4 C
 
Structure in c
Structure in cStructure in c
Structure in c
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
 
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++
 
Data Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn HubData Types | CS8251- Programming in c | Learn Hub
Data Types | CS8251- Programming in c | Learn Hub
 
C structure and union
C structure and unionC structure and union
C structure and union
 
Chap 10(structure and unions)
Chap 10(structure and unions)Chap 10(structure and unions)
Chap 10(structure and unions)
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
 
2 dml
2 dml2 dml
2 dml
 
Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
 
Lecture18 structurein c.ppt
Lecture18 structurein c.pptLecture18 structurein c.ppt
Lecture18 structurein c.ppt
 

Similar to #Jai c presentation

Similar to #Jai c presentation (20)

Structure In C
Structure In CStructure In C
Structure In C
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
 
User defined data types.pptx
User defined data types.pptxUser defined data types.pptx
User defined data types.pptx
 
DS_PPT.ppt
DS_PPT.pptDS_PPT.ppt
DS_PPT.ppt
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Structure.pptx
Structure.pptxStructure.pptx
Structure.pptx
 
Chapter 13.1.9
Chapter 13.1.9Chapter 13.1.9
Chapter 13.1.9
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
DS_PPT.pptx
DS_PPT.pptxDS_PPT.pptx
DS_PPT.pptx
 
Structures
StructuresStructures
Structures
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Unit 1_ADC.pptx
Unit 1_ADC.pptxUnit 1_ADC.pptx
Unit 1_ADC.pptx
 
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++
 
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdfEasy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
 
Lk module4 structures
Lk module4 structuresLk module4 structures
Lk module4 structures
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
 

More from JAI BAMORIYA

Victoria memorial presentation
Victoria memorial presentationVictoria memorial presentation
Victoria memorial presentationJAI BAMORIYA
 
Online movie tickets
Online movie ticketsOnline movie tickets
Online movie ticketsJAI BAMORIYA
 
Memory &amp; its types presentation1
Memory &amp; its types presentation1Memory &amp; its types presentation1
Memory &amp; its types presentation1JAI BAMORIYA
 
Isp final presentation
Isp final presentationIsp final presentation
Isp final presentationJAI BAMORIYA
 

More from JAI BAMORIYA (6)

Victoria memorial presentation
Victoria memorial presentationVictoria memorial presentation
Victoria memorial presentation
 
Jai dbms
Jai dbmsJai dbms
Jai dbms
 
Jai co ppt
Jai co pptJai co ppt
Jai co ppt
 
Online movie tickets
Online movie ticketsOnline movie tickets
Online movie tickets
 
Memory &amp; its types presentation1
Memory &amp; its types presentation1Memory &amp; its types presentation1
Memory &amp; its types presentation1
 
Isp final presentation
Isp final presentationIsp final presentation
Isp final presentation
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
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
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.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
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 

#Jai c presentation

  • 1.
  • 2. CONTENTS :  Introduction of structure  Array of structure  Nested structure  Structure with pointer
  • 3. Introduction - In C/C++, struct keyword is used to define a structure, a structure is the collection of variables with a common name. Structure variables are called fields. A structure is heterogeneous in that it can be composed of data of different types. Structure is an user defined data type.
  • 4.  Simple structure – struct Structure_name{ datatype fieldname1; datatype fieldname2; ………………………; datatype fieldnamen; };
  • 5.
  • 6.
  • 7.
  • 8. The members of a structure are accessed with the dot (.) operator. syntax – structure_var_name.fieldname; : st.rollno; st.st_name; st.per_marks;
  • 9.
  • 10.  In contrast, array is homogeneous since it can contain only data of the same type.  Complex data structures can be formed by defining arrays of structs. syntax – struct structure_name array_name[i]; For Exa : struct student_type st[50];
  • 11.
  • 12. Int main() { struct student st[50]; int I; for(i=0;i<5;i++) {
  • 13. When a structure whose member also of a structure type then such structure are called Nested structure. Nested are of two types – 1) Separate Structure 2) Embedded Structure 1) : We can create two structures, but dependent structure should be used inside the main structure as a member.
  • 14. struct date{ int dd; int mm; int yyyy; }doj; struct employee{ int id; char name[20]; struct date doj; }emp1;
  • 15. 2) Embedded Structure : In this structure, we can define structure within the structure also. struct employee{ int id; char name[20]; struct date{ int dd; int mm; int yyyy; }doj; }emp1;
  • 16. Structure with Pointer -  Pointer variable can point to the address of a structure variable. For Exa – struct dog{ char name[10]; char breed[10]; int age; char colour[10]; }spike; struct dog my_dog={“tyke”,”Bulldog”, 5, “White”}; struct dog *ptr_dog; ptr_dog=&spike;
  • 17. When we want to access member of the structure through pointer, arrow (->) operator is used. For Exa – ptr_dog->name; ptr_dog->breed; Or – (*ptr_dog).name; (*ptr_dog).breed;
  • 18.  For Exa – struct point{ int x; int y; }point; int main() { Point P; printf(“Enter the coordinates of point”); input(&P); output(&P); }
  • 19. void input(point *point_ptr) { scanf(“%d”,&(point_ptr->x)); scanf(“%d”,&(point_ptr->y)); } void output(point p) { printf(“x coordinate=%d”,p.x); printf(“y coordinate=%d”,p.y); }