Trying to get the for loop to work

Have a program I was working on that would make a charter converting Farenheit to Celius I would like to use the for loop here is my cody so far. Sorry if it is not even close.


#include <iostream>
using namespace std;
#include <iomanip>
int ConvertFarenheitToCelcius(int);
int Farenheit(int);
int Celsius(int);
int i;
int main()
{
for(int i = 0;i< 100;i++)
cout << Celsius(i) << " " << Farenheit(i) << endl;
}
int Celsius(int i)
{
Farenheit = (1.8*i)+32;
return Farenheit;
}
int Farenheit(int i)
{
Celsius(i) = ( Farenheit-32)/1.8;

int ConvertFarenheitToCelsius
{
return Celsius;
}

system("PAUSE ");
return 0;
}
Here are some corrections to your code, you should definitely read the tutorials http://www.cplusplus.com/doc/tutorial/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
using namespace std;
#include <iomanip>
int ConvertFarenheitToCelcius(int);
int Farenheit(int);
int Celsius(int);
//   int i;   You don't need this

int main()
{
   for(int i = 0;i< 100;i++)
      cout << Celsius(i) << " " << Farenheit(i) << endl;
// } extra brace

// function definitions moved outside main

/*  The following makes no sense:
   int ConvertFarenheitToCelsius
   {
      return Celsius;
   }
*/

   system("PAUSE ");  // don't use this see http://www.cplusplus.com/forum/articles/7312/
   return 0;
}

int Celsius(int i)
{
   //   Farenheit = (1.8*i)+32;  wrong, Farenheit is a function
   return (1.8*i)+32;  // this is how you should do it
}

int Farenheit(int i)
{
    // Celsius(i) = ( Farenheit-32)/1.8; Nope
    return (i-32)/1.8; // same as function Celsius
}
Topic archived. No new replies allowed.