im having issues with this code. my problem is i need it to continue to run until i enter 0 as the "total". and i also need a setprecision to 1 decimal place on the answer.
#include <iostream>
usingnamespace std;
double sum(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 num[total];
for (int i = 0; i < total; i++)
{
cout << "Enter number " << i + 1 << ":";
cin >> num[i];
}
int sum = 0;
int i = 0;
while (i < total)
{
sum = sum + num[i];
i++;
}
cout << "The average of the numbers you entered is " << sum/total << endl;
return 0;
}