In: Computer Science
Q: In a class there are ‘n’ students. All of them have
appeared for the test. The Teacher who evaluated the
sheets wants to know average marks of the class. Write code to help
the teacher find average
performance, use most appropriate data type/structure for storing
marks.
write the program in c lnguage
Please check the programme which will accpet the Number of students input
and then you have to Enter the Marks for N number of students,
in the output it will show the Average marks of the class, and student wise below and above average marks
PROGRAMM
#include<stdio.h>
#include<conio.h>
struct class{
int marks;
}st[15];
void main()
{
int i,n;
float total=0,Avgmarks;
//clrscr();
printf("\nEnter the number of students in the
class(<=15):");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter student %d marks :",i+1);
scanf("%d",&st[i].marks);
}
for(i=0;i<n;i++)
{
total = total + st[i].marks;
}
Avgmarks=total/n;
printf("\nAverage marks of the class = %.2f",Avgmarks);
for(i=0;i<n;i++)
{
if(st[i].marks>=Avgmarks)
{
printf("\n student %d marks = %d above the
average",i+1,st[i].marks);
}
else
{
printf("\n student %d marks = %d below the
average",i+1,st[i].marks);
}
}
getch();
}