Escolar Documentos
Profissional Documentos
Cultura Documentos
#include<stdio.h>
int main(){
int a1,a2,a3,a4,a5;
printf("Enter Number 1 : ");
scanf("%d",&a1);
printf("Enter Number 2 : ");
scanf("%d",&a2);
printf("Enter Number 3 : ");
scanf("%d",&a3);
printf("Enter Number 4 : ");
scanf("%d",&a4);
printf("Enter Number 5 : ");
scanf("%d",&a5);
printf("The Sum = %d\n",a1+a2+a3+a4+a5);
return 0;
}
91-100 -> Ex
81-90 -> A
71-80 -> B
61-70 -> C
0-60 -> D
(b) You are required to extend the above program so that it assesses the best performer in
the class by taking a simple average of the marks secured by each of the 5 students in the
class.
Parts (a) and (b) should be part of the same program file.
Notes: You should not use loops in this program. You are required to use If and Else
statement.
#include<stdio.h>
int main(){
int a1,a2,a3,aavg,b1,b2,b3,bavg,c1,c2,c3,cavg,d1,d2,d3,davg,e1,e2,e3,eavg;
printf("Student -A \n Enter marks in subject 1 : ");
scanf("%d",&a1 );
if(a1>=91) printf("\tGrade = Ex");
else if(a1>=81) printf("\tGrade = A");
else if(a1>=71) printf("\tGrade = B");
else if(a1>=61) printf("\tGrade = C");
else printf("\tGrade = D");
printf("\nEnter marks in subject 2 : ");
scanf("%d",&a2 );
if(a2>=91) printf("\tGrade = Ex");
else if(a2>=81) printf("\tGrade = A");
else if(a2>=71) printf("\tGrade = B");
else if(a2>=61) printf("\tGrade = C");
else printf("\tGrade = D");
scanf("%d",&e3 );
if(e3>=91) printf("\tGrade = Ex");
else if(e3>=81) printf("\tGrade = A");
else if(e3>=71) printf("\tGrade = B");
else if(e3>=61) printf("\tGrade = C");
else printf("\tGrade = D");
aavg=(a1+a2+a3)/3;
bavg=(b1+b2+b3)/3;
cavg=(c1+c2+c3)/3;
davg=(d1+d2+d3)/3;
eavg=(e1+e2+e3)/3;
if(aavg>bavg&&aavg>cavg&&aavg>davg&&aavg>eavg)
printf("\n\nStudent A has secured the highest score!!");
else if(bavg>aavg&&bavg>cavg&&bavg>davg&&bavg>eavg)
printf("\n\nStudent B has secured the highest score!!");
else if(cavg>aavg&&cavg>bavg&&cavg>davg&&cavg>eavg)
printf("\n\nStudent C has secured the highest score!!");
else if(davg>aavg&&davg>bavg&&davg>cavg&&davg>eavg)
printf("\n\nStudent D has secured the highest score!!");
else printf("\n\nStudent E has secured the highest score!!");
return 0;
}