Ok, I'm learning arrays and I pretty much have the concept of them and how they work.. now my problem is that I dont get how to store things in them...![]()
anyway, I've been working on this problem i'm given and it doesnt look too good:
now.. for some reason, instead of putting the 10 numbers in one array (one demention) it puts each number in a new array....PHP Code:#include <stdio.h>
#define GRADES 10
main()
{
int Ngrades[GRADES] = {0}, i, loop = 1;
float total, avg;
while (loop == 1) {
printf("Please enter %d grades\n", GRADES);
for (i=0; i<10; i++) {
scanf("%d", &Ngrades[i]);
printf("Calculating......");
for (i=0; i<10; i++) {
total += Ngrades[GRADES];
}
avg = (float) total/(Ngrades[GRADES]);
printf("The %d numbers entered were: \n", GRADES);
for (i=0; i<10; i++) {
printf("Ngrades[%d] = %d\n", i, Ngrades[i]);
}
printf("\n");
printf("the avg of the %d numbers was: %.1f\n", GRADES, avg);
}
}
return 0;
}
what I need it to do is get the 10 grades from ther user, display those 10 numbers, then take the average of all of them...
then there are other things like calculating the letter grade based on teh average but for now I want to get this straight
thanks for any help!
-Emo





Reply With Quote