/* Program to accept and display records for 10 students using structs */ /* Problem 30 */ #include #include struct student { long roll_no; char name[20]; int marks[3]; int total; }; main() { struct student st[10]; int sub_w_total; int i,j; clrscr(); sub_w_total = 0; printf("Please enter the following details for 10 students,"); printf("\n"); for (i = 0; i < 10; i++) { printf("\nRoll No : "); scanf("%ld",&st[i].roll_no); printf("Name : "); scanf("%s",&st[i].name); printf("3 subjects' marks obtained (separated by or ) : "); for (j = 0; j < 3; j++) scanf("%d",&st[i].marks[j]); st[i].total = st[i].marks[0] + st[i].marks[1] + st[i].marks[2]; } printf("\n\nSubject Wise Total : "); for (j = 0; j < 3; j++) { for (i = 0; i < 10; i++) sub_w_total += st[i].marks[j]; printf("\nSubject %d Total : %d",(j+1),sub_w_total); sub_w_total = 0; } printf("\n\nStudent Wise Total : "); for (i = 0; i < 10; i++) printf("\nStudent %d Total : %d",(i+1),st[i].total); printf("\n\nPress any key to exit..."); getch(); }