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:(adsbygoogle = window.adsbygoogle || []).push({});

However I keep getting some random compile errors related to the vector. What am I doing wrong here?Code (Text):

#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);

};

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Am I Using Vectors Wrong?

Loading...

Similar Threads - Using Vectors Wrong | Date |
---|---|

Is assembly language still being used? | Sunday at 5:51 PM |

Python Interesting article how to use Pandas with Excel sheets | Feb 19, 2018 |

Need some advice on an appropriate computer language to use | Feb 13, 2018 |

Using MATLAB outside of the lab | Jan 4, 2018 |

3-D plot using 3 vectors in Matlab | Jul 16, 2012 |

**Physics Forums - The Fusion of Science and Community**