0

Loops C++

In a for loop, how do you add the number of the same variable for each loop?

11th Nov 2018, 8:06 PM
Anusha Basnyat
Anusha Basnyat - avatar
5 Respuestas
+ 3
I don't know what you mean, can you show a simple example?
11th Nov 2018, 8:32 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 3
Here I corrected the errors. You forgot to write variables declarations and you got some syntax misstakes too. I added variable 'sum' which counts sum of the missed days. https://code.sololearn.com/cXU6FondIKAd/?ref=app
11th Nov 2018, 8:52 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 1
https://code.sololearn.com/cmG7LIvOx5VD/?ref=app
11th Nov 2018, 8:43 PM
Anusha Basnyat
Anusha Basnyat - avatar
+ 1
https://code.sololearn.com/c6TOtfFvl03A/?ref=app You have to set sum equal to zero in main. If it was declared outside of main, you wouldn't have to, but you should anyways Aleksander Szczepura
11th Nov 2018, 11:00 PM
Zeke Williams
Zeke Williams - avatar
0
So every time the loop happens and I enter a value for “missedDays” I want to add the values of each “missedDays” together.
11th Nov 2018, 8:38 PM
Anusha Basnyat
Anusha Basnyat - avatar