hi people, i needed to write a program that would ask the user for numbers and store them in an array, entering -1 to stop entering numbers. then the program will use a function to find the average of the numbers in the array. the only thing bugging me is i cant get it to stop when you enter -1. thanks for any help or directions to the right way.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int a[1000];
int num;
int total = 0;
int answer;
int i = 0;
void calc_avg( int[] , int, int, int );
while(i != -1) {
printf( "Enter a rating between 0 and 100 " );
scanf( "%d", &num );
a[i] = num;
}
calc_avg(a, num, total, answer);
system("PAUSE");
return 0;
}
void calc_avg( int a[], int num, int total, int answer ) {
int i = 0;
for (i = 0; i < 1000; i++) {
total += a[i];
}
answer = total / i;
printf ("The average of the numbers was: %d", answer);
}