Structures

What is Structure?

The C language allows us to create custom data types. The structure is a custom data type which c combines different data types . The structure is a custom data type which combine different data types to form a new user define data type. Definition A structure is a collection of variable reference under one …

What is Structure? Read More »

Structure Initialization

a structure variable can be initialization as any other data type. Main() { static struct { int weight; float height; } } student{560,080,75}; This assign the value 60 to student weight and 180.75 student height. there is a one to one correspondents between the members and their initializing values. The following statements initialize two structures …

Structure Initialization Read More »

Comparison of structure variables

Two variables of the same structure type can be compared the same way as ordinary variables. operation meaning person1=person2*assign perosn2 to person1 person1== person2*compare all name of person1 and person2 and return1  

Arrays of structures

The most common use of structures is in arrays of structures. To declare an array of structures, first the structure is defined then an array variable of that structure is declared. E.g.: struct class student [100]; It defines an array called student which consists of 100 elements of structure named class. Ans is stored inside …

Arrays of structures Read More »

Arrays with in structures

Single as multidimensional arrays of type int as float can be defined as structure members. Example: struct marks { int number; float subject[3]; } student [2]; Here the member subject contains three elements, subject[0], subject[1] and subject[2] there elements can be accessed using appropriate subscript. For instance, the name student [1] student [2]; would refer …

Arrays with in structures Read More »

Structures with in structures

Structures within a structure means nesting of structures. Example: struct salary { char name [20]; char department [10]; int basic-pay; int dearness-allowance; int huse_rent_allowance; int city_allowance; } employee; This structure defines name, department, basic pay and three kinds of allowances. All the items related to allowance can be grouped together and declared under a sub-stricture. …

Structures with in structures Read More »

Scroll to Top