for loop not iterating correctly

Hey everyone, I'm working on a code using while and for loops to output a table of temperature conversions. Input is degrees in celsius and an increment value, using while loops to prevent input of less than absolute zero and an increment value of at least 1. Then I used a for loop for the table itself, which works mostly fine, except it seems to be iterating the increment value too many times, and the first line in the chart is being output after at least one iteration instead of displaying the original celsius input and conversions first.

This is my for loop:
1
2
3
4
5
6
  for (int ROWS = 1; ROWS < 21; ROWS++)
	{
		cout << ROWS << setw(10) << ((TEMP+=INC)-INC) << setw(10) << ((((TEMP+=INC)-INC)*(1.8)+32)) << setw(10) 
		<< (((TEMP+=INC)-INC)+273.5) << setw(10) << (((TEMP+=INC)-INC)+(273.5)*(9/5)) << endl;
	}
	cout << endl;


My lab partner actually helped me with this part because I couldn't figure out how to work the increment value, so I don't really understand it well enough to figure out why it isn't working.
Last edited on
Do not calculate and show simultaneously. Use helper variables to store computed values.
Are you referring to the conversions? I had set them as constants earlier but the code wasn't working properly. Although now it seems it wasn't defining the constants that was the problem after all. If that's not what you meant then I'm not sure what you did.
Yup, that was it. Took some playing with conversions for a while to make them work properly, but it is now working completely as intended, thank you!
Topic archived. No new replies allowed.