Help on beginner functions

I'm trying to write a simple code using functions to convert temperatures from Fahrenheit to Celsius, I keep getting the error: Primary expression expected before 'float' on line 16 (centigrade = float ftoC(fahrenheit);
Shown below). Any help would be great.

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
 #include <iostream>
#include <iomanip>

using namespace std;

float fToC(float degreesF = 32.0);

int main(){
    float fahrenheit;
    float centigrade;
    float fToC ();

    cout << "Enter a Fahrenheit temperature:\t";
    cin >> fahrenheit;

    centigrade = float ftoC(fahrenheit);

    cout << fahrenheit << "F is " << centigrade << "C";

    cout << endl << "Freezing point:" << fToC() << "C";
    return 0;
}

float fToC(float degreesF){
        float degreesC = ((5.0/9.0)*(degreesF-32.0));
        return degreesC;
        };
First you should remove line 11.

When calling a function you should not put the return type in front of the function name.

You also need to make sure to spell the function correctly. Note that C++ is case sensitive so t is not the same as T.
Excellent thank you for your help, I have dyslexia so sometimes I don't spot the mistakes I make, especially when they are to do with spelling. Again thank you for your help.

For anybody looking for the correct code here it is:

#include <iostream>
#include <iomanip>

using namespace std;

float fToC(float degreesF = 32.0);

int main(){
float fahrenheit;
float centigrade;


cout << "Enter a Fahrenheit temperature:\t";
cin >> fahrenheit;

centigrade = fToC(fahrenheit);

cout << fahrenheit << "F is " << centigrade << "C";

cout << endl << "Freezing point:" << fToC() << "C";
return 0;
}

float fToC(float degreesF){
float degreesC = ((5.0/9.0)*(degreesF-32.0));
return degreesC;
}
Topic archived. No new replies allowed.