hello there,
i need to get 7 different values for a resistor from the user,
then add them up.

how will i go about doing so?
do i store each value the user gives me all in different variables? or is there a way to store them into a single variable?
thanks
i noticed i spelled 'accumulate' incorrectly, sorry

You store the values if you need them later, you don't if you don't need them later. For the sum itself, you will only need a temporary variable to save the input but not a permanent array. To store all of them in a "single variable", that variable will have to be an array (or std::vector). This page on vectors has what you need.

declate a variable in which you will store the sum, declare another variable for input, and every time you get input in the input variable you add it to the sum variable, e.g:

sum += input;

yes, but how do i make the vector add all the integers up?

With a loop:

for (int i = 0; i < vector.size(); ++i) {
  /* add them up */ 
}

or if your allowed to :

int sum = std::accumulate(resistors.begin(), resistors.end(), 0);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.