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
Related Searches

practice quizzes

,

MCQs

,

pdf

,

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

,

Semester Notes

,

Summary

,

ppt

,

Objective type Questions

,

Sample Paper

,

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

,

Previous Year Questions with Solutions

,

mock tests for examination

,

Important questions

,

Extra Questions

,

Free

,

Viva Questions

,

shortcuts and tricks

,

past year papers

,

Exam

,

study material

,

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

,

video lectures

;