Monday, October 6, 2014

structures

 Define Structures. Explain structures in detail. (JAN 2009 / MAY 2009)

A structure is a collection of one or more variables of different data types grouped together under a single name. It contains different data types.
Syntax:
struct struct-name
{
type variable 1; type variable 2; type variable n;
} structure_variables;
Example:
struct student

{
char name[25];
int rollno;
int m1,m2,m3,total;
float avg;
}s1,s2;
· Structure within structure
· Array of structures
· Pointers to structures
· Structures and functions
Example program:
· To define a structure and read the member variable values from user.

· To copy structure elements from one object to another object.

No comments:

Post a Comment