-1

Here is the code in question:

double cf_converter(double t){
    //This function converts from celsius to farenheit
    if (t <= 200 && t >= -200){
        printf("0.00 C ==> 32.00 F");
        return CFR*t+32.00;
    }
    else{
        printf("Invalid Farenheit Temperature\n");
        return pow(t,3);
    }
}

The above function is where the compiler tells me the error is occurring. I have looked at other examples, but I can't determine why I'm getting the error. The error is apparently occurring, according to the compiler, in the first return statement, where it reads CFR*t+32.00.

void main(){
    //Main Loop
    char c;
    double t, o, input;

    printf("Please enter  F or C: ");
    scanf("%c", &c);

    switch(c){
        case 'c':
        case 'C':
            printf("\nPlease enter a celsius degree number: ");
            scanf("%lf", t);
            o = cf_converter(t);
            break;
        case 'f':
        case 'F':
            printf("\nPlease enter a farenheit degree number: ");
            scanf("%lf", t);
            o = fc_converter(t);
            break;
        default:
            printf("\nThat input is unknown.");
            break;
    }
}

The above is my main function, as it's currently written. There is an fc_converter() function that is identical the cf_converter function, except the return statements are slightly different. I'm using stdio.h and math.h for some functions (like pow(t,3)).

And in response to questions, CFR looks like this:

#define CFR = 1.8
gsamaras
  • 71,951
  • 46
  • 188
  • 305
Luke Mathwalker
  • 107
  • 1
  • 6

1 Answers1

5

Change this:

#define CFR = 1.8

to this:

#define CFR 1.8

since the equal sign is not syntactically correct.

Moreover, change this:

scanf("%lf", t);

to this:

scanf("%lf", &t);

since f is of type double. It's exactly the same rational as with the char c;, for which you have correctly passed the address of its scanf call.

PS: What should main() return in C and C++? int, not void.

gsamaras
  • 71,951
  • 46
  • 188
  • 305