I wouldn't calculate a "running" average. Unless you specifically need to keep a running average, don't do it - it's just extra calculation for nothing.
taking your code:
Code:
for (x = 0; x < 10; x++)
{
avg = (array[x] + avg) / x;
if (array[x] == -1)
and removing the running average and adding a sum:
for(x = 0, sum = 0; x < 10; x++)
{
if(array[x] > -1)
sum = sum + array[x];
else
break;
}
//now calculate the sum, just once:
average = sum/x;
The standard idiom or practice in C, with arithmetic like: sum = sum + someNumber, is to use the shorthand: sum += someNumber. Don't be surprised if you see C code like that - it's very common. That applies to subtraction, multiplication, and division, as well as addition.