I wrote this code for an assignment that asked to create a program that calculates and displays the average of any amount of real numbers. The program is supposed to ask the user how many numbers they want to enter and then use a loop to ask the user to enter a number, keeping track of the sum as they are entered, and then calculating the average. I have it somewhat ok, until the end where it's supposed to give the average. I tried a couple things but none of them gave me the right answer. I don't think I'm keeping track of the sum either.

```
#include <iostream>
using namespace std;
double avg(double[],double);
int main ()
{
int total;
cout << "How many numbers would you like to enter? ";
cin >> total;
while (total<=0)
{
cout << "Enter a number: ";
cin >> total;
}
double nums[total];
for (int i=0; i<total; i++)
{
cout << "Enter number" << i+1 << ":";
cin >> nums[i];
}
cout << "The average of the numbers you entered is " << avg(nums,total) << endl;
return 0;
}
double avg(double vals[], double T)
{
}
```