InterviewSolution
| 1. |
Explain the elements of structure definition. Give an example. |
|
Answer» struct <structure-tag> { <data_type> <member variable1> <data_type> <member variable 2>list of members <data_type> < member variable 3> } <structure-variable-name1>,<sttructure-variable-name2>; 1.struct: It is the reserved or keyword used in structure definition. 2. <structure-tag>: It is the name given by the programmer and used to identity the structure in future re-definitions. They are used to declare structure variables. 3. <data_type>: Any valid data type in ‘C’. 4. < member variable 1…4>: are names of the variables. 5. <structure-variable-name 1,.2>: It is used to access the members of the structure. Example: struct student { int SP regno; char name[20]; char class[5]; char combination[4]; float fees; } st1, st2, st3; |
|