- #1
Lancelot59
- 646
- 1
I'm currently learning C++, and I'm trying to use vectors and some simple loops to find the largest/smallest values out of 10 inputted values:
However I keep getting some random compile errors related to the vector. What am I doing wrong here?
Code:
#include iostream
#include string
using namespace std;
int main()
{
vector<double> Values();
double Largest, Smallest, TempVal;
int i;
//Getting the input
while(data.size() < 11)
{
cout << "Input a number and press the enter key: ";
cin >> TempVal;
Values.push_back(TempVal);
};
//Finding The Largest Value
for(i = 0, Largest = Values[0]; i < 10; i++)
{
if(Values[i] > Largest)
{
Largest = Values[i]
};
};
//Finding The Smallest Value
for(i = 0, Smallest = Values[0]; i < 10; i++)
{
if(Values[i] < Smallest)
{
Smallest = Values[i]
};
};
cout << "The largest value is: " << Largest << endl;
cout << "The smallest value is: " << Smallest << endl;
return(0);
};
However I keep getting some random compile errors related to the vector. What am I doing wrong here?