I'm very new to coding and was just playing around with vectors however I cant seem to find out how to add all elements in a vector together when the amount of elements is user-defined.
#include <iostream>
#include <vector>
using namespace std;
int NoOfItems;
int i=1;
double Odds;
double Cost;
vector<double> CaseNumber;
int main()
{
cout << "How many items in the case: ";
cin >> NoOfItems;
while (true) {
if (NoOfItems == 0) {
break;
} else {
cout << "Odds for item " << i <<endl;
cin >> Odds;
CaseNumber.push_back(Odds);
NoOfItems = NoOfItems - 1;
i = i + 1;
}
}
}