I am currently unable to achieve the correct variable for this line of code

include <stdio.h>

main(){
int ftemp ;
double ctemp;
printf("please enter a temperature in fahrenheit\n");
scanf("%d",&ftemp);
ctemp=(ftemp-32)*5/9;
printf("celcius temperature is %d\n",ctemp);
}
The temperature in celsius is calculated as follows:
Celsius temperature = (Fahrenheit temperature – 32) * 5/9

Comments

  • %d is for integers. Either use %f or cast int on your variable.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion