This was an optional assignment but I still wanted to do it... But I am having difficulty doing it.
The assignment said that the user must input 6 quiz grades, and get the average of the quizzes excluding the highest and lowest grade, and do all this for 5 students.
Sample Output:
Enter Student Scores:
Q1=50
Q2=70
Q3=100
Q4=50
Q5=40
Q6=90
Average Score:65 (excluding the highest and the lowest scores)
Enter Student Scores:
Q1=60
Q2=70
Q3=100
Q4=50
Q5=40
Q6=90
Average Score:67.5 (excluding the highest and the lowest scores)
Enter Student Scores:
Q1=50
Q2=70
Q3=90
Q4=50
Q5=40
Q6=70
Average Score:60 (excluding the highest and the lowest scores)
Enter Student Scores:
Q1=80
Q2=70
Q3=100
Q4=50
Q5=40
Q6=90
Average Score:72.5 (excluding the highest and the lowest scores)
Enter Student Scores:
Q1=85
Q2=75
Q3=80
Q4=90
Q5=50
Q6=95
Average Score:82.5 (excluding the highest and the lowest scores)
I am having difficulty on how to exclude the highest and lowest grade input so I cannot proceed with computing the average.
I made two experimental code versions because I don't know which of the two "GRADE INPUT" methods I should use...
Input Method 1
Code:
#include<stdio.h>
float q1,q2,q3,q4,q5,q6,s; /*the set of variables are not final*/
main()
{
clrscr();
printf("Please input scores for 6 quizzes:");
printf("\nQuiz1: "); scanf("%f",&q1);
printf("\nQuiz2: "); scanf("%f",&q2);
printf("\nQuiz3: "); scanf("%f",&q3);
printf("\nQuiz4: "); scanf("%f",&q4);
printf("\nQuiz5: "); scanf("%f",&q5);
printf("\nQuiz6: "); scanf("%f",&q6);
for(s=1;s<=5;s++) /*to repeat the input and computation of grades for 5 times*/
{
/*then I don't know what to do next*/
/*I think it should have contained the code for excluding the min and max value and the average of the 4 values left*/
}
return 0;
}
Input Method 2:
Code:
#include<stdio.h>
float s,g,q; /*the set of variables are not final*/
main()
{
clrscr();
for(s=1;s<=5;s++) /*to repeat the input, computation, and output for 5 students*/
{
printf("Please input scores for 6 quizzes:");
for(g1;g1<=6;g++) /*to input quiz scores for 6 times to correspond for the 6 quizzes required*/
{
printf("Quiz%f",g); scanf("%f",&q);
/*then I don't know what to do next*/
I don't know which is the better input method for the situation...
Please help me which input method is better...
And please help me on how to exclude the highest and lowest value of grade from the computation of the average score...
THANKS!!!