SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Lecture 19Lecture 19
Version 1.0Version 1.0
StructureStructure
2Rushdi Shams, Dept of CSE, KUET, Bangladesh
What is StructureWhat is Structure
 a ‘book’ is a collection of things such as title,a ‘book’ is a collection of things such as title,
author, call number, publisher, number of pages,author, call number, publisher, number of pages,
date of publication, etcdate of publication, etc
 all this data is dissimilarall this data is dissimilar
 author is a string, whereas number of pages is anauthor is a string, whereas number of pages is an
integerinteger
3Rushdi Shams, Dept of CSE, KUET, Bangladesh
What is StructureWhat is Structure
 For dealing with such collections, C provides aFor dealing with such collections, C provides a
data type called ‘structure’data type called ‘structure’
 A structure gathers together, different atoms ofA structure gathers together, different atoms of
information that comprise a given entityinformation that comprise a given entity
 We have seen earlier how ordinary variables canWe have seen earlier how ordinary variables can
hold one piece of informationhold one piece of information
 how arrays can hold a number of pieces ofhow arrays can hold a number of pieces of
information of the same data typeinformation of the same data type
4Rushdi Shams, Dept of CSE, KUET, Bangladesh
What is StructureWhat is Structure
 These two data types can handle a great varietyThese two data types can handle a great variety
of situationsof situations
 But quite often we deal with entities that areBut quite often we deal with entities that are
collection of dissimilar data typescollection of dissimilar data types
5Rushdi Shams, Dept of CSE, KUET, Bangladesh
What is structureWhat is structure
 to store data about a book. You might want toto store data about a book. You might want to
storestore
1.1. its name (a string)its name (a string)
2.2. its price (a float)its price (a float)
3.3. number of pages in it (an int)number of pages in it (an int)
6Rushdi Shams, Dept of CSE, KUET, Bangladesh
What is StructureWhat is Structure
 we can follow two approacheswe can follow two approaches
1.1. Construct individual arrays, one for storingConstruct individual arrays, one for storing
names, another for storing prices and stillnames, another for storing prices and still
another for storing number of pages.another for storing number of pages.
2.2. Use a structure variable.Use a structure variable.
7Rushdi Shams, Dept of CSE, KUET, Bangladesh
What is structureWhat is structure
 Let us examine these two approaches one byLet us examine these two approaches one by
oneone
Making things withMaking things with
ArraysArrays
9Rushdi Shams, Dept of CSE, KUET, Bangladesh
Making things withMaking things with
StructuresStructures
11Rushdi Shams, Dept of CSE, KUET, Bangladesh
Declaration of StructureDeclaration of Structure
and Structure Variablesand Structure Variables
13Rushdi Shams, Dept of CSE, KUET, Bangladesh
Initializing StructureInitializing Structure
VariablesVariables
15Rushdi Shams, Dept of CSE, KUET, Bangladesh
Accessing StructureAccessing Structure
ElementsElements
17Rushdi Shams, Dept of CSE, KUET, Bangladesh
18Rushdi Shams, Dept of CSE, KUET, Bangladesh
Array of StructuresArray of Structures
20Rushdi Shams, Dept of CSE, KUET, Bangladesh

Weitere ähnliche Inhalte

Andere mochten auch

Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systems
Rushdi Shams
 
L4 domain integrity
L4  domain integrityL4  domain integrity
L4 domain integrity
Rushdi Shams
 
Lec 23. Files (Part II)
Lec 23. Files (Part II)Lec 23. Files (Part II)
Lec 23. Files (Part II)
Rushdi Shams
 
Lecture 1 and 2 processes
Lecture 1 and 2  processesLecture 1 and 2  processes
Lecture 1 and 2 processes
Rushdi Shams
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
Rushdi Shams
 
Research methodology
Research methodologyResearch methodology
Research methodology
Rushdi Shams
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocks
Rushdi Shams
 
L7 data model and dbms architecture
L7  data model and dbms architectureL7  data model and dbms architecture
L7 data model and dbms architecture
Rushdi Shams
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
Rushdi Shams
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process models
Rushdi Shams
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
Rushdi Shams
 

Andere mochten auch (13)

Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systems
 
L4 domain integrity
L4  domain integrityL4  domain integrity
L4 domain integrity
 
Lec 23. Files (Part II)
Lec 23. Files (Part II)Lec 23. Files (Part II)
Lec 23. Files (Part II)
 
Lecture 1 and 2 processes
Lecture 1 and 2  processesLecture 1 and 2  processes
Lecture 1 and 2 processes
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
 
Research methodology
Research methodologyResearch methodology
Research methodology
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocks
 
Normal forms
Normal formsNormal forms
Normal forms
 
L7 data model and dbms architecture
L7  data model and dbms architectureL7  data model and dbms architecture
L7 data model and dbms architecture
 
L3 defense
L3  defenseL3  defense
L3 defense
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process models
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
 

Ähnlich wie Lec 19. Structure

Hi,Based on the Data We can Use diffrent type of Data Structure..pdf
Hi,Based on the Data We can Use diffrent type of Data Structure..pdfHi,Based on the Data We can Use diffrent type of Data Structure..pdf
Hi,Based on the Data We can Use diffrent type of Data Structure..pdf
aradhana9856
 
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
Rajeshkumar Reddy
 

Ähnlich wie Lec 19. Structure (20)

Graph-based Approaches for Organization Entity Resolution in MapReduce
Graph-based Approaches for Organization Entity Resolution in MapReduceGraph-based Approaches for Organization Entity Resolution in MapReduce
Graph-based Approaches for Organization Entity Resolution in MapReduce
 
Lecture 19 - Struct and Union
Lecture 19 - Struct and UnionLecture 19 - Struct and Union
Lecture 19 - Struct and Union
 
Comparative study of frequent item set in data mining
Comparative study of frequent item set in data miningComparative study of frequent item set in data mining
Comparative study of frequent item set in data mining
 
Ch1
Ch1Ch1
Ch1
 
Annotating Search Results from Web Databases
Annotating Search Results from Web Databases Annotating Search Results from Web Databases
Annotating Search Results from Web Databases
 
Data Structure - Elementary Data Organization
Data Structure - Elementary  Data Organization Data Structure - Elementary  Data Organization
Data Structure - Elementary Data Organization
 
Topic detecton by clustering and text mining
Topic detecton by clustering and text miningTopic detecton by clustering and text mining
Topic detecton by clustering and text mining
 
Hi,Based on the Data We can Use diffrent type of Data Structure..pdf
Hi,Based on the Data We can Use diffrent type of Data Structure..pdfHi,Based on the Data We can Use diffrent type of Data Structure..pdf
Hi,Based on the Data We can Use diffrent type of Data Structure..pdf
 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database Concepts
 
MS SQL SERVER: Introduction To Database Concepts
MS SQL SERVER: Introduction To Database ConceptsMS SQL SERVER: Introduction To Database Concepts
MS SQL SERVER: Introduction To Database Concepts
 
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdfSTRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
 
Data mining
Data miningData mining
Data mining
 
Data mining
Data miningData mining
Data mining
 
PATTERN DETECTION WITH RARE ITEM-SET MINING
PATTERN DETECTION WITH RARE ITEM-SET MININGPATTERN DETECTION WITH RARE ITEM-SET MINING
PATTERN DETECTION WITH RARE ITEM-SET MINING
 
Data mining
Data miningData mining
Data mining
 
Basics of data structure
Basics of data structureBasics of data structure
Basics of data structure
 
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
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Review on: Techniques for Predicting Frequent Items
Review on: Techniques for Predicting Frequent ItemsReview on: Techniques for Predicting Frequent Items
Review on: Techniques for Predicting Frequent Items
 

Mehr von Rushdi Shams

L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
Rushdi Shams
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
Rushdi Shams
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
Rushdi Shams
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
Rushdi Shams
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
Rushdi Shams
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
Rushdi Shams
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineering
Rushdi Shams
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software fails
Rushdi Shams
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Rushdi Shams
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
Rushdi Shams
 

Mehr von Rushdi Shams (20)

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better Research
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IR
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processing
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: Parsing
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
L15 fuzzy logic
L15  fuzzy logicL15  fuzzy logic
L15 fuzzy logic
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
 
First order logic
First order logicFirst order logic
First order logic
 
Belief function
Belief functionBelief function
Belief function
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
 
L4 vpn
L4  vpnL4  vpn
L4 vpn
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
 
L1 phishing
L1  phishingL1  phishing
L1 phishing
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineering
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software fails
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
 

Kürzlich hochgeladen

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Kürzlich hochgeladen (20)

Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
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Ữ Â...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
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
 
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.
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

Lec 19. Structure

  • 1. Lecture 19Lecture 19 Version 1.0Version 1.0 StructureStructure
  • 2. 2Rushdi Shams, Dept of CSE, KUET, Bangladesh What is StructureWhat is Structure  a ‘book’ is a collection of things such as title,a ‘book’ is a collection of things such as title, author, call number, publisher, number of pages,author, call number, publisher, number of pages, date of publication, etcdate of publication, etc  all this data is dissimilarall this data is dissimilar  author is a string, whereas number of pages is anauthor is a string, whereas number of pages is an integerinteger
  • 3. 3Rushdi Shams, Dept of CSE, KUET, Bangladesh What is StructureWhat is Structure  For dealing with such collections, C provides aFor dealing with such collections, C provides a data type called ‘structure’data type called ‘structure’  A structure gathers together, different atoms ofA structure gathers together, different atoms of information that comprise a given entityinformation that comprise a given entity  We have seen earlier how ordinary variables canWe have seen earlier how ordinary variables can hold one piece of informationhold one piece of information  how arrays can hold a number of pieces ofhow arrays can hold a number of pieces of information of the same data typeinformation of the same data type
  • 4. 4Rushdi Shams, Dept of CSE, KUET, Bangladesh What is StructureWhat is Structure  These two data types can handle a great varietyThese two data types can handle a great variety of situationsof situations  But quite often we deal with entities that areBut quite often we deal with entities that are collection of dissimilar data typescollection of dissimilar data types
  • 5. 5Rushdi Shams, Dept of CSE, KUET, Bangladesh What is structureWhat is structure  to store data about a book. You might want toto store data about a book. You might want to storestore 1.1. its name (a string)its name (a string) 2.2. its price (a float)its price (a float) 3.3. number of pages in it (an int)number of pages in it (an int)
  • 6. 6Rushdi Shams, Dept of CSE, KUET, Bangladesh What is StructureWhat is Structure  we can follow two approacheswe can follow two approaches 1.1. Construct individual arrays, one for storingConstruct individual arrays, one for storing names, another for storing prices and stillnames, another for storing prices and still another for storing number of pages.another for storing number of pages. 2.2. Use a structure variable.Use a structure variable.
  • 7. 7Rushdi Shams, Dept of CSE, KUET, Bangladesh What is structureWhat is structure  Let us examine these two approaches one byLet us examine these two approaches one by oneone
  • 8. Making things withMaking things with ArraysArrays
  • 9. 9Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 10. Making things withMaking things with StructuresStructures
  • 11. 11Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 12. Declaration of StructureDeclaration of Structure and Structure Variablesand Structure Variables
  • 13. 13Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 15. 15Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 17. 17Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 18. 18Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 19. Array of StructuresArray of Structures
  • 20. 20Rushdi Shams, Dept of CSE, KUET, Bangladesh