where is the error i cant find it
where is the error? It says this:
grades.c: In function `main':
grades.c:7: error: array size missing in `grade'
grades.c:7: error: conflicting types for `grade'
grades.c:7: error: previous declaration of `grade'
grades.c:58: error: subscripted value is neither array nor pointer
grades.c:59: error: subscripted value is neither array nor pointer
grades.c:61: error: subscripted value is neither array nor pointer
grades.c:62: error: subscripted value is neither array nor pointer
grades.c:64: error: subscripted value is neither array nor pointer
grades.c:65: error: subscripted value is neither array nor pointer
grades.c:71: error: syntax error before "int"
grades.c:77: error: syntax error before ')' token
grades.c:80: error: subscripted value is neither array nor pointer
grades.c:81: error: subscripted value is neither array nor pointer
grades.c:81: error: subscripted value is neither array nor pointer
grades.c:83: error: subscripted value is neither array nor pointer
grades.c:83: error: subscripted value is neither array nor pointer
grades.c:85: error: subscripted value is neither array nor pointer
grades.c:85: error: subscripted value is neither array nor pointer
grades.c:87: error: subscripted value is neither array nor pointer
grades.c:87: error: subscripted value is neither array nor pointer
grades.c:89: error: subscripted value is neither array nor pointer
grades.c:89: error: subscripted value is neither array nor pointer
SOURCE CODE:
#include<stdio.h>
#include<math.h>
main()
{
int j, c, grade[], number_of_grades, sum, I, grade, grade_total = 0, failure_count = 0;
double pow(double x, double y);
double sqrt(double x);
double standard_dev;
float average, variance, high, low;
printf("How many grades will you be entering?"
"(must be in between 0 and 100");
scanf("%i", &number_of_grades);
if ( number_of_grades < 0 || number_of_grades > 100){
printf("ERROR: You have entered a number to large"
"or to small for the program to calculate"
"number must be in between 0 and 100, and"
"must be a whole number.\n");
return 0;
}
for(I=1; I <= number_of_grades; ++i )
{
printf("Enter grade #%i:", I);
scanf("%i", &grade );
if (grade < 0){
printf("ERROR: You have entered a number"
"not within the domain.\n");
return 0;}
if (grade > 100){
printf("ERROR: You have entered a number"
"not within the domain.\n");
return 0;}
grade_total = grade_total + grade;
if ( grade < 65 )
++failure_count;
average = (float) grade_total / number_of_grades;
sum = 0;
for (I=0;i<=number_of_grades-1;++i){
sum = sum + pow((grade - average),2);
}
variance = sum / (number_of_grades - 1);
standard_dev = sqrt(variance);
high = grade[0];
low = grade[0];
for( I=1;i<=number_of_grades -1;++i ){
if (grade[i] > high){
high = grade[i];
}
if (grade[i] < low){
low = grade[i];
}
}
int c[5]
int c[4]
int c[3]
int c[2]
int c[1]
int c[0]
for (j=0; j<=4; ++j){
c [j]=0}
for (I=0; I<= number_of_grades-1;++i){
if (grade[i] > 89)
c[0] = c[0] + 1;
else if (grade > 79)
c[1] = c[1] + 1;
else if (grade > 69)
c[2] = c[2] + 1;
else if (grade > 59)
c[3] = c[3] + 1;
else
c[4] = c[4] + 1;
}
printf("\nGrade average = %.2f\n", average );
printf("Number of failures = %i\n", failure_count );
return 0;
}
|