Short Notes: Nested Structure | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE) PDF Download

Download, print and study this document offline
Please wait while the PDF view is loading
 Page 1


NESTED STRUCTURES
The structure that contains another structure as its members is called a nested structure or a 
structure within a structure is called nested structure. The structure should be declared separately 
and then be grouped into high level structure.
1 . Write a program to read and display the information of all the students in the class using 
nested structure.
Passing Structures through pointers
Pointer to a structure is a variable that holds the address of a structure. The syntax to declare 
pointer to a structure can be given as:
strcut struct name *ptr;
To assign address of stud to the pointer using address operator(&) we would write 
ptr_stud= &stud;
To access the members of the structure (->) operator is used. 
for example 
Ptr_stud->name =Raj;
SELF REFERENTIAL STRUCTURE
Self -referential structures are those structures that contain a reference to data of its same type as 
that of structure.
Example
struct node
{
int val;
struct node*next;
};
Page 2


NESTED STRUCTURES
The structure that contains another structure as its members is called a nested structure or a 
structure within a structure is called nested structure. The structure should be declared separately 
and then be grouped into high level structure.
1 . Write a program to read and display the information of all the students in the class using 
nested structure.
Passing Structures through pointers
Pointer to a structure is a variable that holds the address of a structure. The syntax to declare 
pointer to a structure can be given as:
strcut struct name *ptr;
To assign address of stud to the pointer using address operator(&) we would write 
ptr_stud= &stud;
To access the members of the structure (->) operator is used. 
for example 
Ptr_stud->name =Raj;
SELF REFERENTIAL STRUCTURE
Self -referential structures are those structures that contain a reference to data of its same type as 
that of structure.
Example
struct node
{
int val;
struct node*next;
};
Pointers to Structures
You can define pointers to structures in very similar way as you define pointer to any other 
variable as follows:
struct books *struct_pointer;
Now, you can store the address of a structure variable in the above defined pointer variable. To 
find the address of a structure variable, place the & operator before the structure's name as 
follows:
struct_pointer = &book1;
To access the members of a structure using a pointer to that structure, you must use the -> 
operator as follows:
struct_pointer->title;
1 .Write a program to display, add and subtract two time defined using hour, minutes and values 
of seconds.
2. Write a program, using pointer to structure, to initialize the members in the structure. Use 
functions to print the students information.
3. Write a program using an array of pointers to a structure to read and display the data of a 
student.
Read More
90 docs

Top Courses for Computer Science Engineering (CSE)

Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Free

,

study material

,

Extra Questions

,

ppt

,

Objective type Questions

,

shortcuts and tricks

,

Sample Paper

,

Short Notes: Nested Structure | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE)

,

Semester Notes

,

Summary

,

Short Notes: Nested Structure | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE)

,

practice quizzes

,

pdf

,

Previous Year Questions with Solutions

,

past year papers

,

Viva Questions

,

mock tests for examination

,

Important questions

,

MCQs

,

Exam

,

video lectures

,

Short Notes: Nested Structure | Short Notes for Computer Science Engineering - Computer Science Engineering (CSE)

;