Given a Fahrenheit temperature F, this question requires writing a program to calculate the corresponding Celsius temperature C
. The C=5×(F−32)/9
formula: . The question guarantees that the input and output are within the integer range.
Input format:
Enter a temperature in Fahrenheit on one line.
Output format:
“Celsius = C”
Output the corresponding C
integer value of Celsius temperature in one line according to the format .
Input sample:
150
Sample output:
Celsius = 65
Code:
# include <stdio.h>
# include <stdlib.h>
int main(){
int Celsius,fahr;
scanf("%d",&fahr);
Celsius = 5 * (fahr - 32) / 9;
printf("Celsius = %d",Celsius);
return 0;
}
Submit screenshot:
Problem-solving ideas:
This question is similar to the previous one. You need to enter a piece of data, but the data entered here is an integer, so use it %d
to pass in!