my variable doesnt seem to catch and keep the highest score...
when you go through the program, it doesnt seem to catch the highest user entered score, its weird cos im not good at this yet, im just chucking code at it but nothing as come from it....
would really appreciate a few pointers or nudges in the right direction, or a solution but definatley informing me of where ive gone wrong .
many thanks for reading this
gruffy
#include <stdio.h>
#define BIG 100
/* Declare an array to hold expenses, and a counter variable */
int grades[4], i,big, low;
int count, sum, avg;
main()
{
/* Input data from keyboard into array */
printf("Please enter your students marks to find out average, highest and lowest\n\n");
for (count = 0; count < 20; count++)
{
printf("Enter Grade %d: ", count);
scanf("%d", &grades[count]);
sum=sum + grades[count];
avg=sum / 20;
big=grades[0];
{
if(grades[count]>BIG)
big=grades[count];
else
if(grades[count]<low)
low=grades[count];
}
printf("\nLargest Number is=%d\nSmallest Number is=%d ",big,low);
}
printf("\n\nThe sum of all the grades is: %d", sum);
printf("\nThe Average grade is: %d\n\n", avg);
}

New Topic/Question
Reply



MultiQuote




|