### Celsius to Fahrenheit using Pass by Values

I cant seem to make it work can anyone help me?

#include <stdio.h>
#include <stdlib.h>

float cf(int *c)
{
float fen;
fen = (1.8 * (*c)) + 32;
return fen;

int main()
{
float cel, fen;

printf ("Enter the value of Temperature in Celcius: ");

scanf ("%f", &cel);
fen = cf(&c);
printf ("The value of Temperature in Fahreinheit is: %.2f", fen);

system("PAUSE");
return 0;
}
This should work:

 ``12345678910111213141516171819202122232425`` ``````#include #include float cf(int *c) { float fen; fen = (1.8 * (*c)) + 32; return fen; } int main() { float cel, fen; int c; printf ("Enter the value of Temperature in Celcius: "); scanf ("%f", &cel); fen = cf(&c); printf ("The value of Temperature in Fahreinheit is: %.2f", fen); system("PAUSE"); return 0; }``````

@OP(original poaster): Please use code tags.
-You did not end the definition of function cf
-You called it wrongly
Last edited on
the answer still does not come out right
but it helped..but still does not work

 ``123456789101112131415161718192021222324`` ``````#include #include float cf(int *cal) { float fen; fen = (1.8 * (*cal)) + 32; return fen; } int main() { float c; printf ("Enter the value of Temperature in Celcius: "); scanf ("%f", &c); printf ("The value of Temperature in Fahreinheit is: %.2f\n", cf(&c)); system("PAUSE"); return 0; }``````
tell me the conversion rate please cause I don't know.
as in celsius to kelvin is either +273 or -273 so what is that of celsius to fahrenheit?
Last edited on
http://lmgtfy.com/?q=celcius+to+farenheit

celcius temp * 9 / 5 + 32 = Fahrenheit

`float cf(int *cal)`
...
`float c;`

you are using &c and c is a float

so change it to

`float cf(float *cal)`
Last edited on
Thanks Maniax.

C++ code:
 ``12345678910111213141516171819202122`` ``````#include using namespace std; int main() { double celcius; double far; int x=10; do{ system("CLS"); cout<<"Please enter a value to be converted to fahrenheit: "; cin>>celcius; far=celcius*9/5+32; cout<<"\nAns: "<
Topic archived. No new replies allowed.