Experiment 2-2-2 Calculating the temperature in degrees Celsius (10 points)

Given a Fahrenheit temperature F, this question requires writing a program to calculate the corresponding Celsius temperature C. The C=5×(F−32)/9formula: . 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 Cinteger 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:

Insert picture description here

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 %dto pass in!

Guess you like

Origin blog.csdn.net/weixin_43862765/article/details/114364663