#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char name[20];
int usn;
int marks;
} stud;
int main()
{
int i, n;
float avg = 0;
stud st[50];
printf(“enter the number of students\n”);
scanf(“%d”, &n);
printf(“enter the student details\n”);
for (i = 0; i < n; i++)
{
printf(“\n name:”);
scanf(“%s”, st[i].name);
printf(“\n usn:”);
scanf(“%d”, &st[i].usn);
printf(“\n marks:”);
scanf(“%d”, &st[i].marks);
avg = avg + st[i].marks;
}
avg = avg / n;
for (i = 0; i < n; i++)
{
printf(“\n name \t %s”, st[i].name);
printf(“\n usn \t %d”, st[i].usn);
printf(“\n marks\t:%d\n”, st[i].marks);
if (st[i].marks < avg)
printf(“the student is below the average\n”);
else
printf(“the student is above average\n”);
}
}
Implement structures to read, write, and compute average-marks and the students scoring above and below the average marks for a class of N students.
2 Answers