Counter Problem

I need the left side column to increase in increments of 2 but the output is in increments of 4. The right side column is doing what I want it to but I can't figure out why it is going in increments of 4 instead of two.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// The counter.
	const int min_number = 2;
	const int max_number = 66;
	int num = min_number;	// Counter
	double timeCalc = (num / fill_rate);
	cout << "Your fill rate is 2 inches every " << timeCalc << " hours." << endl;


		cout << "Time Intervals Per 2 Inches Gained" << endl;
		cout << "----------------------------------" << endl;
		while (num <= max_number)
		{
		cout << num << "\t\t" << timeCalc << endl;
		num = num + 2;
		timeCalc = (num = num + 2) / fill_rate;

		}
line 14 you're setting num = num + 2
then you're doing it again on line 15. So you are adding 4 to num between line 14 and line 15

new line 14
num += 2

new line 15
timeCalc = (num + 2) / fill_rate;


FYI
num = num + 2

can be simplified by doing

num += 2
Topic archived. No new replies allowed.