# Thread: Whats wrong in my code?

1. ## Whats wrong in my code?

Implement the following two functions
/* returns Celsius equivalent of a Fahrenheit temperature (ft) */
double celsius(double ft); this part doesn't want to work check code please.

/* returns Fahrenheit equivalent of a Celsius temperature (ct) */
double fahrenheit (double ct); this part Done and works

Code:
```#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double f2c(int f);
double c2f(int i);

int main ( void )
{
int i, f;
double Celsius, Fahrenheit;

printf("\n\t Celsius<->Fahrenheit\n\n\n");

for ( i = 0; i <= 100; i += 2)
{
Fahrenheit = c2f(i);

printf ( "\t%3d \t - %6.2f \n",  i, Fahrenheit);
}

printf("\n\tFahrenheit<->Celsius \n");
for ( f = 32; f <= 212; f += 4) {

Celsius = f2c(f);

printf ( "\t%3d  \t - %6.2f \n",  f, Celsius);

}

system("pause");
}

/*Implementation Fahrenheit to Celsius*/

double f2c(int f)
{
return (5.0 / 9.0) * (f - 32.0);
}

/*Implementation Celsius to Fahrenheit*/ /* NOT Working*/
/*What Exactly I need to change Here*/

double c2f(int i)

return (9.0 / 5.0) * i) + 32;
{

}```
Don't assume i know exactly what i have to change that's why I'm asking, I'm begineer and I'm just learning C. If i have anymore errors please let me know where to correct it. Thanks

[B]Errors I Get:[/B]

In function `double c2f(int)':
40 expected identifier before '(' token
40 named return values are no longer supported

2. Put the return for c2f inside the curly braces.

3. Also, does anything look a little "mismatched" here:
Code:
`       return (9.0 / 5.0) * i) + 32;`

4. Originally Posted by Adak
Put the return for c2f inside the curly braces.
I already did that and still gives me the same errors. i know is a very small error and I already tried days to get this far in this complicated code for me; easy for you and if you would show me how to do it I'll appreciated, If i see it i will learn better not to do that error again.

5. All I did was change c2f to look like this, and now the program compiles and works without error:
Code:
```double c2f(int i)
{

return (9.0 / 5.0) * i + 32;

}```
so it has braces in the right place, and no extra ) after i (the compiler will make that a smiley face

You should be using a text editor with syntax highlighting for C that will point out simple things like extra unclosed braces.

6. Originally Posted by MK27
All I did was change c2f to look like this, and now the program compiles and works without error:
Code:
```double c2f(int i)
{

return (9.0 / 5.0) * i + 32;

}```
so it has braces in the right place, and no extra ) after i (the compiler will make that a smiley face

You should be using a text editor with syntax highlighting for C that will point out simple things like extra unclosed braces.

Thanks a lot, it really helped me.

Popular pages Recent additions