#include<stdio.h>
#include<conio.h>
#define STU_NUM 3
#define NAME_LEN 100
#define SUB_NUM 3
struct student
{
int id;
char name[NAME_LEN];
char group;
int subject_marks[SUB_NUM];
int total;
int percentage;
};
void main()
{
int i, j, k, l, total, percentage;
struct student stud[STU_NUM];
clrscr();
//Get the required data from user.
for(i=0; i<STU_NUM; i++)
{
j = i+1;
printf("\n\nEnter the ID of student %d: ",j);
scanf("%d",&stud[i].id);
fflush(stdin);
printf("\nEnter the name of student %d: ",j);
gets(stud[i].name);
fflush(stdin);
printf("\nEnter the group selected by student %d (A/B): ",j);
scanf("%c",&stud[i].group);
fflush(stdin);
for(k=0; k<SUB_NUM; k++)
{
l = k+1;
printf("\nEnter the marks of subject %d for student %d: ",l,j);
scanf("%d",&stud[i].subject_marks[k]);
}
fflush(stdin);
}
//Calculate total & percentage of the student.
for(i=0; i<STU_NUM; i++)
{
total = 0;
percentage = 0;
for(k=0; k<SUB_NUM; k++)
{
total = total + stud[i].subject_marks[k];
}
percentage = total / SUB_NUM;
stud[i].total = total;
stud[i].percentage = percentage;
}
//Display the progress report of the students.
clrscr();
for(i=0; i<STU_NUM; i++)
{
printf("ID: %d \t Name: %s \t Group: %c \n", stud[i].id, stud[i].name, stud[i].group);
for(k=0; k<SUB_NUM; k++)
{
l = k+1;
printf("Subject %d: %d / 100 \n", l, stud[i].subject_marks[k]);
}
printf("Total: %d \t Percentage: %d \n", stud[i].total, stud[i].percentage);
printf("\n----------------------------------------------------------------------\n\n");
}
getch();
}
#include<conio.h>
#define STU_NUM 3
#define NAME_LEN 100
#define SUB_NUM 3
struct student
{
int id;
char name[NAME_LEN];
char group;
int subject_marks[SUB_NUM];
int total;
int percentage;
};
void main()
{
int i, j, k, l, total, percentage;
struct student stud[STU_NUM];
clrscr();
//Get the required data from user.
for(i=0; i<STU_NUM; i++)
{
j = i+1;
printf("\n\nEnter the ID of student %d: ",j);
scanf("%d",&stud[i].id);
fflush(stdin);
printf("\nEnter the name of student %d: ",j);
gets(stud[i].name);
fflush(stdin);
printf("\nEnter the group selected by student %d (A/B): ",j);
scanf("%c",&stud[i].group);
fflush(stdin);
for(k=0; k<SUB_NUM; k++)
{
l = k+1;
printf("\nEnter the marks of subject %d for student %d: ",l,j);
scanf("%d",&stud[i].subject_marks[k]);
}
fflush(stdin);
}
//Calculate total & percentage of the student.
for(i=0; i<STU_NUM; i++)
{
total = 0;
percentage = 0;
for(k=0; k<SUB_NUM; k++)
{
total = total + stud[i].subject_marks[k];
}
percentage = total / SUB_NUM;
stud[i].total = total;
stud[i].percentage = percentage;
}
//Display the progress report of the students.
clrscr();
for(i=0; i<STU_NUM; i++)
{
printf("ID: %d \t Name: %s \t Group: %c \n", stud[i].id, stud[i].name, stud[i].group);
for(k=0; k<SUB_NUM; k++)
{
l = k+1;
printf("Subject %d: %d / 100 \n", l, stud[i].subject_marks[k]);
}
printf("Total: %d \t Percentage: %d \n", stud[i].total, stud[i].percentage);
printf("\n----------------------------------------------------------------------\n\n");
}
getch();
}