I’m using Visual C++ 2010 Express Edition. I declared an integer array capable of holding 50 elements. Depending on how many entries the user gives, each of those entries will be stored as a separate element in the array. I want to add up all these unknown elements and print the answer to the console. Is it possible to do this, and how?
I’m using Visual C++ 2010 Express Edition. I declared an integer array capable of
Share
You’re looking for
std::accumulate()from header<numeric>:If the user gives less then 50 elements then you need to account for that: