Hello,

I am trying to write a program where you enter an undefined amount of numbers and when you type in -1 it will output the average of the numbers you have entered. I am having trouble figuring out how to keep storing a new number. I figure I need a variable for the amount of numbers entered, and one for each of the numbers entered but it has to be unlimited.

Here is what i have so far and I don't know if I have the right idea. it doesnt work and when I run it I get runtime errors.

Code:#include <stdio.h> #include <math.h> int main(void) { int n,newnumber,average,count=0,total; printf("enter numbers: \n"); while (n != -1, newnumber != -1) { scanf_s("%lf",&n); scanf_s("%lf",&newnumber); total=n+newnumber; count++; } if (n==-1,newnumber==-1) average=total/count; printf("average is: %i",average); getchar(); return 0; }