# Help With Temperature Conersion chart

• 11-06-2003
sanmaximo
Help With Temperature Conersion chart
So far I have gotten the temperature conversions from fahrenehit to celsius to print out properly. But when it comes to Celsius to Fahrenehit it prints out 65 constantly as well as 15.56 fahrenheit constantly. Our teacher mentioned something about Pass By Reference but im not sure were to use it. Any help is appreciated.
Shawn
Here is the CODE
Code:

```#include <iostream> using namespace std; int main() {          cout.precision(2);   cout.setf(ios::fixed); const int LOWER = 0; const int UPPER = 60; const int STEP = 5;         int fahr = LOWER;         double celsius = 0;                 /* Print table heading */         cout.width(19);         cout << "Fahrenheit";         cout.width(12);         cout << "Celsius";         cout.width(20);         cout << endl;         /* print table from LOWER to UPPER */         for (fahr = LOWER ; fahr <= UPPER ; fahr += STEP)             {         cout.width(15);         cout << fahr;         celsius = (double(5)/9) * (fahr - 32);         cout.width(15);         cout << celsius;         cout.width(15);         cout <<endl;               } const int LOWER1 =0; const int UPPER1 =60; const int STEP1 =10;   int cels = LOWER1;   double fahrenheit = 0;   cout.width(17);   cout<<endl <<endl;         cout << "Celsius";         cout.width(15);         cout << "Fahrenheit";         cout.width(20);         cout << endl; for (cels = LOWER1; cels <= UPPER1 ; cels += STEP1) {         cout.width(15);         cout << fahr;         fahrenheit = (double(9)/5 * cels) + 32;         cout.width(15);         cout << celsius;         cout.width(15);         cout <<endl; }         return 0; }```
• 11-06-2003
PJYelton
Its because in your second loop you are using the variables from your first loop instead of the variables for the second loop. You are looping cels and updating fahrenheit, but printing celsius and fahr. You need a better system for variable names to keep stupid things like this from happening.
• 11-06-2003
sanmaximo
Temperature Conversion
Could some help me change the code that it stops printing out copies. Thanks for the help
• 11-06-2003
PJYelton
Copies of what? Doing what I said above would fix it from printing the same number over and over again if that is what you mean, otherwise I don't understand what you are asking.