Experiment 2-1-2 Temperature Conversion (5 points)

This question requires writing a program to calculate the Celsius temperature corresponding to a Fahrenheit temperature of 150°F. Calculation formula: C=5×(F−32)/9 , where: C represents temperature in Celsius, F represents temperature in Fahrenheit, and the output data is required to be an integer.

Input format:

This question has not been entered.

Output format:

Output in the following format

fahr = 150, celsius = 计算所得摄氏温度的整数值

Code:

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

int main(){
    
    
    int fahr = 150,celsius;
    celsius = 5 * (fahr - 32) / 9;
    printf("fahr = %d, celsius = %d",fahr,celsius);
    return 0;
}

Submit screenshot:

Insert picture description here

Guess you like

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