I am receiving the following error: Subscripted value is not an array, pointer, or vector. Can anyone advise on how to fix this issue? I am receiving the error in the void GetData function at the bottom on the line that reads " vals[valCount] = value; ". Thank you!
#include <iostream>
#include <iomanip>
#include <array>
using namespace std;
//function declarations
void GetData(double vals, int valCount);
void Sort(double vals, int valCount);
double Variance(double vals, int valCount);
double StandardDev(double vals, int valCount);
double SqRoot(double value); //use for StandardDev function
//function definitions
int main ()
{
double sum = 0,
variance = 0,
standardDev = 0,
vals = 0;
int valCount = 0; //number of values to be processed
//ask user how many values
cout << "Enter the number of values (0 - 100) to be processed: ";
cin >> valCount;
//process and store input values
GetData(vals, valCount);
//output
cout << "\nValues in Sorted Order: " << sum;
cout << "\n\nThe variance for the input value list is: " << variance;
cout << "\nThe standard deviation for the input list is: " << standardDev;
cout << "\n\nPress any value to exit this program\n" << endl;
return 0;
}
//process and store data
void GetData(double vals, int valCount)
{
int value; valCount = 0;
cout << "Enter a value: ";
cin >> value;
while (value != 0) {
vals[valCount] = value;
valCount++;
cout << "/nEnter a value: ";
cin >> value;
}
}
valsis not an array/vector:double vals. Perhaps it should bedouble *vals.