I've written a small c++ program to do a calculation based on a simple algorithm. What I'm trying to do is run the algorithm multiple times and add all the values for print out a total value at the end of the loop.
For refence here is the algorithm:
2^y * 25 * 100^(z/100)
Y would be a value input by the user, Z would also be a value from 1-100.
Here is my For Loop:
for(int i=0;i<SkillLeft;i++){
SkillLevel = SkillLevel+0.01;
float SubTotal = BasePower*25*(pow (100,SkillLevel));
Total = DerpTotal+SubTotal;
cout << "Sub: " << SubTotal << endl;
cout << "Total: " << Total << endl;
}
When this is ran with the rest of my code it calculates correctly, but instead of adding each subtotal to the total, it basically just multiplies it by 2.
So how can I get it to add each subtotal iteration to a total without "resetting" the varible.
gdbon Linux) and to compile with warnings and debugging info enabled (e.g.g++ -Wall -gon Linux). Familiarity with the debugger is a required skill.