SlideShare a Scribd company logo
STRUCTURESTRUCTURE in CC
programming…
Group : ASTUTE
Soummo Supriya : 151-15-4741
T.M. Ashikur Rahman : 151-15-4971
Md. Fazle Rabbi Ador : 151-15-5482
Tasnuva Tabassum Oshin : 151-15-4673
Masumer Rahman : 151-15-5040
Introduction
• Md. Fazle Rabbi adoR
• 151-15-5482
Structure
• A structure is a collection of variables of
different data types under a single name.
• The variables are called members of the
structure.
• The structure is also called a user-defined
data type.
3
Defining a Structure
• Syntax:
struct structure_name
{
data_type member_variable1;
data_type member_variable2;
………………………………;
data_type member_variableN;
};
Note: The members of a structure do not occupy
memory until they are associated with a
structure_variable.
4
struct student
{
char name[20];
int roll_no;
float marks;
char gender;
long int phone_no;
};
•Multiple variables of struct student type can be
declared as:
struct student st1, st2, st3; 5
Example
Defining a structure…Defining a structure…
• Each variable of structure has its own
copy of member variables.
• The member variables are accessed using
the dot (.) operator or member operator.
• For example: st1.name is member
variable name of st1 structure variable
while st3.gender is member variable
gender of st3 structure variable.
6
struct student
{
char name[20];
int ID;
float CSE_marks;
char gender;
long int phone_no;
};
void main()
{
struct student st1={"Ishtiaque",5482,13.5,'M',16021548};
struct student st2={"Oshin",4288,15,'F',19845321};
printf ("Name: %s ID: %d CSE Marks: %.1f Gender: %c Phn: %d
n",st1.name,st1.ID,st1.CSE_marks,st1.gender,st1.phone_no);
printf ("Name: %s ID: %d CSE Marks: %.1f Gender: %c Phn: %d
n",st2.name,st2.ID,st2.CSE_marks,st2.gender,st2.phone_no);
}
7
Pointers to structurePointers to structure
A pointer is a memory address.
You can define pointers to
structures in very similar way as
you define pointer to any other
variable
Prepared By Soummo Spriya
151-15-4741
Declaration of pointers
• Referencing pointer to
another address to access
memory
• Using dynamic memory
allocation
Structure's member through
pointer can be used in two ways:
““Structure within anotherStructure within another
StructureStructure
(Nested Structure)”(Nested Structure)”
Md.Masumer Rahman
Id: 151-15-5040
What is Nested Structure
• Nested structure in C is nothing but structure within
structure. One structure can be declared inside other
structure as we declare structure members inside a
structure. The structure variables can be a normal
structure variable or a pointer variable to access the
data.
• Nested Structures are allowed in C Programming
Language.
• We can write one Structure inside another structure
as member of another structure.
Let’s see the structure declaration below,
Way 1: Declare two separate structures
struct date
{
int date;
int month;
int year;
};
struct Employee
{
char ename[20];
int ssn;
float salary;
struct date doj;
}
emp1;
Way 2 : Declare Embedded structures
struct Employee
{
char ename[20];
int ssn;
float salary;
struct date
{
int date;
int month;
int year;
}
doj;
}
emp1;
Function and Structure
Name: T.m.
ashikur rahmaN
id: 151-15-4971
Function and Structure
We will consider four cases
here:
Passing the individual member to
functions
 Passing whole structure to functions
Passing structure pointer to functions
Passing array of structure to functions
Passing the individual member to
functions
 Structure members can be
passed to functions as actual
arguments in function call
like ordinary variables.
PASSING WHOLE STRUCTURE TO
FUNCTIONS
 Whole structure can be passed to a function
by the syntax:
function _ name ( structure _ variable _
name );
 The called function has the form:
return _ type function _ name (struct tag _ name
structure _ variable _ name)
{
…………;
}
Passing structure pointer to
functions
 In this case, address of structure
variable is passed as an actual argument
to a function.
The corresponding formal argument must
be a structure type pointer variable.
Passing array of structure to function
 Passing an array of structure type to a
function is similar to passing an array of
any type to a function.
 That is, the name of the array of
structure is passed by the calling function
which is the base address of the array of
structure.
 Note: The function prototype comes after
the structure definition.
Arrays of structuresArrays of structures
• Tasnuva Tabassum Oshin
• 151-15-4673
Arrays of structures
• An ordinary array: One type of data
• An array of structs: Multiple types of data
in each array element.
0 1 2 … 98 99
0 1 2 … 98 99
Arrays of structures
• We often use arrays of structures.
• Example:
StudentRecord Class[100];
strcpy(Class[98].Name, “bangladeshi man");
Class[98].Id = 12345;
strcpy(Class[98].Dept, "COMP");
Class[98].gender = 'M';
Class[0] = Class[98]; Bangladeshi man
12345 M
COMP
. . .
0 1 2 … 98 99
Arrays inside structures
• We can use arrays inside structures.
• Example:
struct square{
point vertex[4];
};
square Sq;
• Assign values to Sq using the given square
x y x y x y x y
(4, 3) (10, 3)
(4, 1) (10, 1)
Structure in C
Structure in C

More Related Content

What's hot

Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
Hridoy Bepari
 
Structure in C language
Structure in C languageStructure in C language
Structure in C language
CGC Technical campus,Mohali
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
Kamal Acharya
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 
Strings
StringsStrings
Strings
Mitali Chugh
 
Control structures in C
Control structures in CControl structures in C
Structure & union
Structure & unionStructure & union
Structure & union
Rupesh Mishra
 
Strings in c
Strings in cStrings in c
Strings in c
vampugani
 
C Structures And Unions
C  Structures And  UnionsC  Structures And  Unions
C Structures And Unions
Ram Sagar Mourya
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
sangrampatil81
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Jayanshu Gundaniya
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
Union In language C
Union In language CUnion In language C
Union In language C
Ravi Singh
 
String functions in C
String functions in CString functions in C
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
Nitesh Kumar Pandey
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
sai tarlekar
 
pointers
pointerspointers
pointers
teach4uin
 

What's hot (20)

Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
Structure in C language
Structure in C languageStructure in C language
Structure in C language
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
 
Strings
StringsStrings
Strings
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Strings in c
Strings in cStrings in c
Strings in c
 
C Structures And Unions
C  Structures And  UnionsC  Structures And  Unions
C Structures And Unions
 
Strings in C
Strings in CStrings in C
Strings in C
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Union In language C
Union In language CUnion In language C
Union In language C
 
String functions in C
String functions in CString functions in C
String functions in C
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
pointers
pointerspointers
pointers
 

Viewers also liked

Structure c
Structure cStructure c
Structure c
thirumalaikumar3
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
David Livingston J
 
Structure in c
Structure in cStructure in c
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
Shubham Sharma
 
Array in c language
Array in c languageArray in c language
Array in c language
home
 
String c
String cString c

Viewers also liked (6)

Structure c
Structure cStructure c
Structure c
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Structure in c
Structure in cStructure in c
Structure in c
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
 
Array in c language
Array in c languageArray in c language
Array in c language
 
String c
String cString c
String c
 

Similar to Structure in C

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
 
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
 
Structures and Pointers
Structures and PointersStructures and Pointers
Structures and Pointers
Prabu U
 
1. structure
1. structure1. structure
1. structure
hasan Mohammad
 
Cs1123 12 structures
Cs1123 12 structuresCs1123 12 structures
Cs1123 12 structures
TAlha MAlik
 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
psaravanan1985
 
data structure and c programing concepts
data structure and c programing conceptsdata structure and c programing concepts
data structure and c programing concepts
kavitham66441
 
Structure
StructureStructure
Structure
Frijo Francis
 
Pointers and Structures
Pointers and StructuresPointers and Structures
Pointers and Structures
Gem WeBlog
 
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 & union
Structure & unionStructure & union
Structure & union
lalithambiga kamaraj
 
Pointers and Structures.pptx
Pointers and Structures.pptxPointers and Structures.pptx
Pointers and Structures.pptx
Sharon Manmothe
 
Structure In C
Structure In CStructure In C
Structure In C
yndaravind
 
Structures_Final_KLE (2).pptx
Structures_Final_KLE (2).pptxStructures_Final_KLE (2).pptx
Structures_Final_KLE (2).pptx
ShreevatsaAlawandi
 
Struct
StructStruct
Struct
Fahuda E
 
Programming in C session 3
Programming in C session 3Programming in C session 3
Programming in C session 3
Prerna Sharma
 
CHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptxCHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptx
GebruGetachew2
 
Structures in C
Structures in CStructures in C
Structures in C
Nimrita Koul
 
C structure and union
C structure and unionC structure and union
C structure and union
Thesis Scientist Private Limited
 

Similar to Structure in C (20)

User defined data types.pptx
User defined data types.pptxUser defined data types.pptx
User defined data types.pptx
 
Structures
StructuresStructures
Structures
 
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
 
Structures and Pointers
Structures and PointersStructures and Pointers
Structures and Pointers
 
1. structure
1. structure1. structure
1. structure
 
Cs1123 12 structures
Cs1123 12 structuresCs1123 12 structures
Cs1123 12 structures
 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
 
data structure and c programing concepts
data structure and c programing conceptsdata structure and c programing concepts
data structure and c programing concepts
 
Structure
StructureStructure
Structure
 
Pointers and Structures
Pointers and StructuresPointers and Structures
Pointers and Structures
 
Fundamentals of Structure in C Programming
Fundamentals of Structure in C ProgrammingFundamentals of Structure in C Programming
Fundamentals of Structure in C Programming
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Pointers and Structures.pptx
Pointers and Structures.pptxPointers and Structures.pptx
Pointers and Structures.pptx
 
Structure In C
Structure In CStructure In C
Structure In C
 
Structures_Final_KLE (2).pptx
Structures_Final_KLE (2).pptxStructures_Final_KLE (2).pptx
Structures_Final_KLE (2).pptx
 
Struct
StructStruct
Struct
 
Programming in C session 3
Programming in C session 3Programming in C session 3
Programming in C session 3
 
CHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptxCHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptx
 
Structures in C
Structures in CStructures in C
Structures in C
 
C structure and union
C structure and unionC structure and union
C structure and union
 

More from Fazle Rabbi Ador

Online Shopping Agent in AI
Online Shopping Agent in AIOnline Shopping Agent in AI
Online Shopping Agent in AI
Fazle Rabbi Ador
 
00 java basic programming in Bangla|| Introduction
00 java basic programming in Bangla|| Introduction00 java basic programming in Bangla|| Introduction
00 java basic programming in Bangla|| Introduction
Fazle Rabbi Ador
 
Types of memory in Computer
Types of memory in ComputerTypes of memory in Computer
Types of memory in Computer
Fazle Rabbi Ador
 
Error Finding in Numerical method
Error Finding in Numerical methodError Finding in Numerical method
Error Finding in Numerical method
Fazle Rabbi Ador
 
Cloning Bio-Informative
Cloning Bio-InformativeCloning Bio-Informative
Cloning Bio-Informative
Fazle Rabbi Ador
 
Amd Athlon Processors
Amd Athlon ProcessorsAmd Athlon Processors
Amd Athlon Processors
Fazle Rabbi Ador
 
Data Mining & Applications
Data Mining & ApplicationsData Mining & Applications
Data Mining & Applications
Fazle Rabbi Ador
 
Electromagnetic induction & useful applications
Electromagnetic induction & useful applicationsElectromagnetic induction & useful applications
Electromagnetic induction & useful applications
Fazle Rabbi Ador
 
Bangladesh Cricket Team.
Bangladesh Cricket Team.Bangladesh Cricket Team.
Bangladesh Cricket Team.
Fazle Rabbi Ador
 
Application of mathematics in daily life
Application of mathematics in daily lifeApplication of mathematics in daily life
Application of mathematics in daily life
Fazle Rabbi Ador
 
Application of mathematics in daily life
Application of mathematics in daily lifeApplication of mathematics in daily life
Application of mathematics in daily life
Fazle Rabbi Ador
 
SIXTH SENSE-TECHNOLOGY
SIXTH SENSE-TECHNOLOGYSIXTH SENSE-TECHNOLOGY
SIXTH SENSE-TECHNOLOGY
Fazle Rabbi Ador
 

More from Fazle Rabbi Ador (12)

Online Shopping Agent in AI
Online Shopping Agent in AIOnline Shopping Agent in AI
Online Shopping Agent in AI
 
00 java basic programming in Bangla|| Introduction
00 java basic programming in Bangla|| Introduction00 java basic programming in Bangla|| Introduction
00 java basic programming in Bangla|| Introduction
 
Types of memory in Computer
Types of memory in ComputerTypes of memory in Computer
Types of memory in Computer
 
Error Finding in Numerical method
Error Finding in Numerical methodError Finding in Numerical method
Error Finding in Numerical method
 
Cloning Bio-Informative
Cloning Bio-InformativeCloning Bio-Informative
Cloning Bio-Informative
 
Amd Athlon Processors
Amd Athlon ProcessorsAmd Athlon Processors
Amd Athlon Processors
 
Data Mining & Applications
Data Mining & ApplicationsData Mining & Applications
Data Mining & Applications
 
Electromagnetic induction & useful applications
Electromagnetic induction & useful applicationsElectromagnetic induction & useful applications
Electromagnetic induction & useful applications
 
Bangladesh Cricket Team.
Bangladesh Cricket Team.Bangladesh Cricket Team.
Bangladesh Cricket Team.
 
Application of mathematics in daily life
Application of mathematics in daily lifeApplication of mathematics in daily life
Application of mathematics in daily life
 
Application of mathematics in daily life
Application of mathematics in daily lifeApplication of mathematics in daily life
Application of mathematics in daily life
 
SIXTH SENSE-TECHNOLOGY
SIXTH SENSE-TECHNOLOGYSIXTH SENSE-TECHNOLOGY
SIXTH SENSE-TECHNOLOGY
 

Recently uploaded

End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
GetInData
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
74nqk8xf
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
u86oixdj
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
mzpolocfi
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
Bill641377
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
Sachin Paul
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
soxrziqu
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
v7oacc3l
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 

Recently uploaded (20)

End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 

Structure in C

  • 1. STRUCTURESTRUCTURE in CC programming… Group : ASTUTE Soummo Supriya : 151-15-4741 T.M. Ashikur Rahman : 151-15-4971 Md. Fazle Rabbi Ador : 151-15-5482 Tasnuva Tabassum Oshin : 151-15-4673 Masumer Rahman : 151-15-5040
  • 2. Introduction • Md. Fazle Rabbi adoR • 151-15-5482
  • 3. Structure • A structure is a collection of variables of different data types under a single name. • The variables are called members of the structure. • The structure is also called a user-defined data type. 3
  • 4. Defining a Structure • Syntax: struct structure_name { data_type member_variable1; data_type member_variable2; ………………………………; data_type member_variableN; }; Note: The members of a structure do not occupy memory until they are associated with a structure_variable. 4
  • 5. struct student { char name[20]; int roll_no; float marks; char gender; long int phone_no; }; •Multiple variables of struct student type can be declared as: struct student st1, st2, st3; 5 Example
  • 6. Defining a structure…Defining a structure… • Each variable of structure has its own copy of member variables. • The member variables are accessed using the dot (.) operator or member operator. • For example: st1.name is member variable name of st1 structure variable while st3.gender is member variable gender of st3 structure variable. 6
  • 7. struct student { char name[20]; int ID; float CSE_marks; char gender; long int phone_no; }; void main() { struct student st1={"Ishtiaque",5482,13.5,'M',16021548}; struct student st2={"Oshin",4288,15,'F',19845321}; printf ("Name: %s ID: %d CSE Marks: %.1f Gender: %c Phn: %d n",st1.name,st1.ID,st1.CSE_marks,st1.gender,st1.phone_no); printf ("Name: %s ID: %d CSE Marks: %.1f Gender: %c Phn: %d n",st2.name,st2.ID,st2.CSE_marks,st2.gender,st2.phone_no); } 7
  • 8.
  • 9. Pointers to structurePointers to structure A pointer is a memory address. You can define pointers to structures in very similar way as you define pointer to any other variable Prepared By Soummo Spriya 151-15-4741
  • 11. • Referencing pointer to another address to access memory • Using dynamic memory allocation Structure's member through pointer can be used in two ways:
  • 12.
  • 13. ““Structure within anotherStructure within another StructureStructure (Nested Structure)”(Nested Structure)” Md.Masumer Rahman Id: 151-15-5040
  • 14. What is Nested Structure • Nested structure in C is nothing but structure within structure. One structure can be declared inside other structure as we declare structure members inside a structure. The structure variables can be a normal structure variable or a pointer variable to access the data. • Nested Structures are allowed in C Programming Language. • We can write one Structure inside another structure as member of another structure.
  • 15. Let’s see the structure declaration below,
  • 16. Way 1: Declare two separate structures struct date { int date; int month; int year; }; struct Employee { char ename[20]; int ssn; float salary; struct date doj; } emp1;
  • 17. Way 2 : Declare Embedded structures struct Employee { char ename[20]; int ssn; float salary; struct date { int date; int month; int year; } doj; } emp1;
  • 18.
  • 19. Function and Structure Name: T.m. ashikur rahmaN id: 151-15-4971
  • 20. Function and Structure We will consider four cases here: Passing the individual member to functions  Passing whole structure to functions Passing structure pointer to functions Passing array of structure to functions
  • 21. Passing the individual member to functions  Structure members can be passed to functions as actual arguments in function call like ordinary variables.
  • 22. PASSING WHOLE STRUCTURE TO FUNCTIONS  Whole structure can be passed to a function by the syntax: function _ name ( structure _ variable _ name );  The called function has the form: return _ type function _ name (struct tag _ name structure _ variable _ name) { …………; }
  • 23. Passing structure pointer to functions  In this case, address of structure variable is passed as an actual argument to a function. The corresponding formal argument must be a structure type pointer variable.
  • 24. Passing array of structure to function  Passing an array of structure type to a function is similar to passing an array of any type to a function.  That is, the name of the array of structure is passed by the calling function which is the base address of the array of structure.  Note: The function prototype comes after the structure definition.
  • 25. Arrays of structuresArrays of structures • Tasnuva Tabassum Oshin • 151-15-4673
  • 26. Arrays of structures • An ordinary array: One type of data • An array of structs: Multiple types of data in each array element. 0 1 2 … 98 99 0 1 2 … 98 99
  • 27. Arrays of structures • We often use arrays of structures. • Example: StudentRecord Class[100]; strcpy(Class[98].Name, “bangladeshi man"); Class[98].Id = 12345; strcpy(Class[98].Dept, "COMP"); Class[98].gender = 'M'; Class[0] = Class[98]; Bangladeshi man 12345 M COMP . . . 0 1 2 … 98 99
  • 28. Arrays inside structures • We can use arrays inside structures. • Example: struct square{ point vertex[4]; }; square Sq; • Assign values to Sq using the given square x y x y x y x y (4, 3) (10, 3) (4, 1) (10, 1)