new to using classes in C -


# include <stdio.h>  int main(void) {  int numstudents; int = 0 ; int sum;  printf("how many students in class? \n"); scanf("%d", &numstudents);  int grade[numstudents];   while ( < numstudents ){       scanf("%d", &grade[i]);       printf("\n");       i++;       }  average(int grade[numstudents]); printf("%d", &sum);       }   int average(int x[y]){     int sum;      (a=0; a<=y ;a++){     sum = sum + x[a];     }      sum = sum / y;     return sum; } 

i asking wrong code.

for starters, this

int average(int x[y]){           /* wrong */ int average(int x[], int y){     /* want */ 

and

average(int grade[numstudents]); /* totally wrong */ average(grade, numstudents);     /* might work */ 

there off-by-one errory in average i'm not pointing out since it's homework. urge other posters not point out.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -