I have a homework assignment where I'm supposed to use pass by references. I'm reading my text and don't really get it. The assignment is to create a program that converts Fahrenheit to Celsius and vise versa. It's also supposed to contain a print function that will output the results while using the pass by references. If anyone can look at my code and point me in the right direction, i'd really appreciate it.
#include <iostream>
using namespace std;
void menu();
void ftoc(int f);
void ctof(int c);
int main()
{
int fahrenheit;
int celsius;
int option;
do
{
menu();
cin >> option;
cout << endl;
switch (option)
{
case 1:
ftoc(fahrenheit);
break;
case 2:
ctof(celsius);
break;
case 99:
break;
default:
cout << "Invalid Entry. Try Again" << endl <<endl;
}
}
while (option !=99);
return 0;
}
void menu()
{
cout << "Enter--" << endl;
cout << "1: Convert Fahrenheit to Celsius" << endl;
cout << "2: Convert Celsius to Fahrenheit" << endl;
cout << "99: To quit the program" << endl;
}
void ftoc(int)
{
cout << "Fahrenheit To Celsius Converter. ";
int fahren;
cout << "Enter Fahrenheit Temperature: ";
cin >> fahren;
int celsius;
celsius = (fahren-32)*5/9;
cout << fahren << " Degrees Fahrenheit = " << celsius << " Degrees Celsius " <<endl <<endl;
}
void ctof(int)
{
cout << "Celsius to Fahrenheit Converter. ";
int celsius;
cout << "Enter Celsius Temperature: ";
cin >> celsius;
int fahren;
fahren = (celsius*9/5)+32;
cout << celsius << " Degrees Celsius = " << fahren << " Degrees Fahrenheit " << endl << endl;
}