Page 11 - Data Struct
P. 11

11
                   Algorithm and Data Structure


                   Example 3


                      struct  student
                     {
                          char name [20];

                          char address [30];
                         int age;
                          int phone;

                      }  sem1{“Ali”,”232 jalan bahagia “,20, 0126666633};


                          Accessing element of structure

                          •  To access each field of variable, a point (.)is inserted
                              between the variable name and the field name


                          •  For example:  to access variable name for student1
                                               student1. name
   6   7   8   9   10   11   12   13   14