Array of Structures Assignment Help

Assignment Help: >> Arrays >> Array of Structures

Array of Structures

                  A structure is simple to define if there are only one or two elements but in case there are too many objects needed for a structure, for example a structure designed to show the data of each student of the class, than in that case the array will be introduced a structure declaration using arrays to define objects is given below:

                  Struct student

                  {

                                    Char name[15] :

                                    Int rollno;

                                    Char sex;

                  } ;

                  Student data [50]

                  The above declaration sets the memory space for 50 objects.

Initializing Array of Structures

The arrays of structure can also be initialized same as array data in C. it is to noted that only static or external variable can initialized. A simple example of initializing the array objects of a structure is given below:

                  Struct employee

                  {

                                    Int number;

                                    Char sex;

                                    Int salary;

                  } ;

Employee data [3]= {{146, 'm' , 1000 }, {200, 'f' 5000}, {250, 'm' 10000}};

The above initialized values will be assigned by the compiler as ;

                  Data [0].number = 46       data [0], sex = 'm'                      data [0].salary=1000

                  Data [1], number = 200    data [1], sex = 'f'                        data [1], salary= 5000

                  Data [2], number = 250    data [2], sex = 'm'                      data [2], salary=10000

If in case the structure object or any elements of structure are not initialized the compiler will automatically assign zero to the field of that particular record. For example for above

                  Employee data [3] = {{146, 'm'}, {200, 'f'}, {250, 'm'} } ;

The values assigned by the compiler for the above declaration will be

                  Data [0], number = 146    data [0], sex = 'm'                      data [0], salary = 0

                  Data [1], number = 200    data [1], sex = 'f'                        data [1], salary = 0

                  Data [2], number = 250    data [2], sex = 'm'                      data [2], salary = 0

 

Data Structure & Algorithms Assignment Help, Live Experts 

Struggling with data structure problems? Data structure subject is quite tough to learn? Need quick assistance in data structure questions? ExpertsMind.com is right place for you where your search ends, We at ExpertsMind offer online data structure assignment help, data structure homework help and data structure and algorithms question's answers by best online support by qualified tutors.


ExpertsMind.com - Array of Structures Assignment Help, Array of Structures Homework Help, Array of Structures Assignment Tutors, Array of Structures Solutions, Array of Structures Answers, Arrays Assignment Tutors

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd