At Ask Me Help Desk you can ask questions in any topic and have them
answered for free by our experts. To ask questions or participate in
answering them you must register for a free account. By registering you
will be able to:
Get free answers from experts in any of our 300+
topics.
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
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;
}
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 );
first error is that grade[] requires a number for the size of the array, like grade[10].
Also, you can't define an array and an int with the same name "grade".
hard to find the next errors since you didn't include line numbers. i can tell you there are places where you use grade by itself without any index.
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;
}
looks like your program is cut off before the end. can you paste it again or point to which line above the error is supposed to be on? also, always give the entire error message so I know what to look for.