plz help me in this code . its not giving the output
plz correct my code

#include <stdio.h> 
int main()
{
double fahr , celsius;
printf("Enter the temperature in degrees fahrenheit:");
scanf("%d",fahr);
//convert to celsius
celsius = (5.0 / 9.0) * (fahr - 32.0);
printf("%if temperature in celsius",celsius);

return 0;
}

Edited 6 Years Ago by WaltP: Added CODE Tags

well...none of you gave the solution..so i'm giving it...correct me if i'm wrong...after all i'm rookie too..;)

#include <stdio.h>
int main()
{
double fahr , celsius;
printf("Enter the temperature in degrees fahrenheit:");
scanf("%lf",&fahr);
//convert to celsius
celsius = (5.0 / 9.0) * (fahr - 32.0);
printf("%lf temperature in celsius",celsius);

return 0;
}

Note: however use of scanf is not recommended...use fgets instead...
more inforemation here and here

Edited 6 Years Ago by urbangeek: n/a

Comments
Do NOT give solutions in these forums. We give HELP. We aren't a homework service.

@WaltP...i was just trying to help and he already wrote the program himself, i just showed him where he did wrong... i think there was no need to give me a negative feedback....just my two cents...:icon_neutral:

Edited 6 Years Ago by urbangeek: n/a

@WaltP...i was just trying to help and he already wrote the program himself, i just showed him where he did wrong... i think there was no need to give me a negative feedback....just my two cents...:icon_neutral:

No you didn't. You never pointed showed him his error. You simply posted (allegedly) working code with the statement

well...none of you gave the solution..so i'm giving it...correct me if i'm wrong...

you state yourself you are giving the solution. Also, he never responded so you have no idea if he ever got correct code.

And you did ask to be corrected if you were wrong -- I corrected you.

correct me if i'm wrong

double celsius;
printf("%lf temperature in celsius",celsius);

I think it was Dave Sinkula who once corrected me about this printf/double and %lf.
That line should rather read ..

printf("%f temperature in celsius", celsius);

In C99, the printf("%lf") should have no effect, though (it's ignored).

This article has been dead for over six months. Start a new discussion instead.