Write a program that reads a number, N, and then reads N numbers (integers) betw
ID: 3639742 • Letter: W
Question
- Write a program that reads a number, N, and then reads N numbers (integers) between 0 and 100 representing the marks obtained by students in some subject. Then the program does the following:
(a) It prints the average (mean) marks.
(b) It prints the variance and standard deviation of the marks.
(c) It prints the number of students receiving the grades Ex, A, B, C, D, and P respectively.
(d) It prints the grade obtained by the maximum number of students.
You have to submit one program only. It is advisable to do part (a), check whether it works, and then add part (b) into your program, check whether it works, and so on.
If you have completed all parts well before the stipulated time, then make a copy of the program and modify it so that the numbers are read from a file a2.in instead of the standard input.
Regardless of whether you have completed all parts, some parts, or no parts, you must submit the program file a2.c by 4:15 PM. No submission will be accepted after this time. Students failing to submit by this time will get zero in the assignment. Please write your roll number and name in the program file (under comments).
Explanation / Answer
#include
#include
main()
{
int x,N;
int y,a=0,b=0,c=0,d=0,e=0,p=0,f=0,i;
float A=0,T=0,M,V,S;
printf(" Enter the number of students:");
scanf("%d",&N);
for(i=1;i<=N;i++)
{
printf(" Enter the marks of student%d:",i);
scanf("%d",&x);
T=T+x;
A=A+pow(x,2);
if( x>=90 )
e++;
else
if( x>=80 )
a++;
else
if( x>=70 )
b++;
else
if( x>=60 )
c++;
else
if( x>=50 )
d++;
else
if( x>=35 )
p++;
else
f++;
}
M=T/N;
V=(A/N)-pow(M,2);
S=sqrt(V);
printf(" The average(mean)marks of students in the subject is %f",M);
printf(" The variance of marks of students is %f",V);
printf(" The standard deviation of the marks is %f",S);
printf(" No. of students securing grade Ex is %d",e);
printf(" No. of students securing grade A is %d",a);
printf(" No. of students securing grade B is %d",b);
printf(" No. of students securing grade C is %d",c);
printf(" No. of students securing grade D is %d",d);
printf(" No. of students securing grade P is %d",p);
printf(" No. of students securing grade F is %d",f);
y = e;
if(a>e)
y=a;
if(b>a)
y=b;
if(c>b)
y=c;
if(d>c)
y=d;
if(p>d)
y=p;
if(f>p)
y=f;
if( y==e )
printf(" Maximum students secured grade Ex ");
if( y==a )
printf(" Maximum students secured grade A ");
if( y==b )
printf(" Maximum students secured grade B ");
if( y==c )
printf(" Maximum students secured grade C ");
if( y==d )
printf(" Maximum students secured grade D ");
if( y==p )
printf(" Maximum students secured grade P ");
if( y==f )
printf(" Maximum students secured grade F ");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.