URGENT!!!

can someone help me. plissss..



#include <stdlib.h>

float celsius_at_depth (int d, float c);
float fahrenheit_at_depth (float c, float f);

int main (void)
{
int depth;
float cel, fer;

printf("\nPlease enter depth (in kilometres) inside the earth : ");
scanf("%d", &depth);

celsius_at_depth (depth, cel);
fahrenheit_at_depth (cel, fer);

printf("\nHi dear, my name is Farah.\n");
printf("\nFor the depth of %d km, the temperatures are: ", depth);
printf("\n%.2f degrees Celsius or %.2f degrees Fahrenheit.\n\n", cel, fer);

system("PAUSE");
return (0);
}

float celsius_at_depth (int d, float c)
{
c = (10 * d)+ 20;
}

float fahrenheit_at_depth (float c, float f)
{
f = (1.8 * c )+ 32;
}



the problem is the celsius and farenheit is not compile???
Last edited on
What is the problem?

Please use code tags [code] code here [/code]. It makes it much easier to read your code and therefore easier to help you.
the problem is the output for degree celcius and fahrenheit is not coming out.
The functions doesn't return anything and you never set the value of cel and fer.
can you explain more peter because im very new in this c language and can you show me how to return the value for cel and fer. :-)
Both celsius_at_depth and fahrenheit_at_depth has return type float. That means that the functions are supposed to return a float. To return a value from a function you use the return keyword as you have done in the main function.

c and f inside the functions are just copies of cel and fer so any changes to c and f will not affect cel and fer.

If you use return instead of assignment inside the two functions you don't need the second parameter. Instead you can use assignment in main to give cel and fer the values returned from the functions.
thank you vey much peter. thank you for you kindnest. do you have skype or facebook so i can learn from you. thank you.
No I don't have skype or facebook.
Last edited on
Topic archived. No new replies allowed.