Structures_Session_1
Structures_Session_1
STRUCTURES
Definition, Declaration, accessing structures, initialization, operations on structures, structures containing
arrays, structures containing pointers, nested structures, self-referential structures, arrays of structures,
structures and functions, structures and pointers.
Method 2:
struct structure_name
{
datatype1 var1,var2,…;
datatype2 var1,var2,…;
…………… . ……………
datatypen var1,var2,…;
}var1,var2,var3,…..varn;
Method3:
struct
{
datatype1 var1,var2,…;
datatype2 var1,var2,…;
datatypen var1,var2,…;
}var1,var2,var3,…..varn;
✓ The method 3 cannot be used for future declaration of variables as structure tag is not present.
Note: The use of structure tag is optional in C language.
✓ For example, Variables for structure book are declared in 3 different ways:
Example1:
struct book
{
char name ;
float price ;
int pages ;
} ;
struct book b1, b2, b3 ;