Accessing Element in Structure Array
- Array of Structure can be accessed using dot[.] operator.
- Here Records of 3 Employee are Stored.
- 'for loop' is used to Enter the Record of first Employee.
- Similarly 'for Loop' is used to Display Record.
Output :#include<stdio.h> #include<conio.h> struct Employee { int ssn; char ename[20]; char dept[20]; }emp[3]; //--------------------------------------------- void main() { int i,sum; //Enter the Employee Details for(i=0;i<3;i++) { printf("\nEnter the Employee Details : "); scanf("%d %s %s",&emp;[i].ssn,emp[i].ename,emp[i].dept); } //Print Employee Details for(i=0;i<3;i++) { printf("\nEmployee SSN : %d",emp[i].ssn); printf("\nEmployee Name : %d",emp[i].ename); printf("\nEmployee Dept : %d",emp[i].dept); } getch(); }
Enter the Employee Details : 1 Ram Testing Employee SSN : 1 Employee Name : Ram Employee Dept : Testing


0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email