I'm currently reading "The Programming Principles" book. It has shown me some vector examples, such as this code:
#include "std_lib_facilities.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector <double> temps;
double temp = 0;
double sum = 0;
double high_temp = 0;
double low_temp = 0;
while (cin >> temp)
temps.push_back(temp);
for (int i = 0; i<temps.size(); ++i)
{
if (temps[i] > high_temp) high_temp = temps[i];
if (temps[i] < low_temp) low_temp = temps[i];
sum += temps[i];
}
cout << "High temperature: " << high_temp << endl;
cout << "Low temperature: " << low_temp << endl;
cout << "Average temperature: " << sum / temps.size() << endl;
return 0;
}
I don't know what it means when it uses temps[i]
putting int i = 0
inside of the brackets. So, what does it indicate? I hope I made myself clear.