Slideshow

Monday 25 February 2013


Can a structure be used within a structure? Give appropriate examples to support
your answer




Ans:
Yes, a structure can be used within a structure called nesting of structures. For
example, inside a structure rectangle, a point (x,y) needs to be represented. So we
can first declare a structure point as:
struct point
{ int x;
int y;
};
We can now use this definition in defining points in any of geometrical figure.
For example
struct rectangle
{ struct point pt;
int diagonal;

No comments:

Post a Comment