structuresa structure is a derived data type it


Structures

A structure is a derived data type. It is a combination of logically related data items. Unlike arrays, which are a collection of such as data types, structures can be made of members of unlike data type. The data items in the structures usually belong to the same entity, like information of an employee, players etc.

The general format of structure declaration is:

struct tag

                 {

                                type member1;

                                type member2;

                                type member3;

                                :

                                :

}variables;

We can omit the variable declaration in the structure declaration and explain it separately as follows :

struct tag variable;

In C++ we can omit struct and simply write :

tag variable;

e.g.

Structure definition.

                struct account

                 {

                                int accnum;

                                char acctype;

                                char name[25];

                                float balance;

                 };

 

Structure declaration.

struct account oldcust; [or]

account newcust;

We can refer to the member variables of the structures by using a dot operator (.).

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: structuresa structure is a derived data type it
Reference No:- TGS0309301

Expected delivery within 24 Hours