user defined function help

Hey guys,

I'm a beginner at C++ and was trying my hand on a few assignments...i've reached a point where i am stuck and dont know how to proceed. Any help would be appreciated.
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
using namespace std;

void menu();
void ftoc (int fahrenheit, int celsius);
void ctof (int fahrenheit, int celsius);

int main()
{
    int fahrenheit, celsius;
    int option;
    do
    {
     menu();
     cin >> option;
     cout << endl;
     switch (option)
     {
    case 1:
        cout << "Enter Fahrenheit: ";
        cin >> fahrenheit;
        cout << endl;
        ftoc(fahrenheit, celsius);
        cout << fahrenheit << " celsius";
        break;
    case 2:
        cout << "Enter Celsius: ";
        cin >> celsius;
        cout << endl;
        ctof(celsius, fahrenheit);
        cout << celsius << " Fahrenheit ";
        break;
        
    case 99:
        break;
    
    default:
        cout << "invalid input." << 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 f,int c)
{
 int celsius;
 int fahrenheit;
 c = (fahrenheit-32)*5/9;   
    }

void ctof (int f, int c)
{
 int fahrenheit;
 int celsius;
 f = (celsius*9/5)+32;  
    }
Last edited on
Well your syntax for functions isn't correct, take a look here: http://www.cplusplus.com/doc/tutorial/functions/
Thanks for the link..will read it..I'm just really confused...the program works...but doesn't ends after you enter something...it doesn't go into the user defined fuctions
Topic archived. No new replies allowed.