Experiment 2-1-6 Calculate Fahrenheit temperature (5 points)

This question requires writing a program to calculate the Fahrenheit temperature corresponding to a temperature of 26°C. Calculation formula:, F=9×C/5+32where: Cindicates the temperature in Celsius, Findicates the 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

celsius = 26, fahr = 对应的华氏温度整数值

Code:

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

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

Submit screenshot:

Insert picture description here

Precautions:

At the beginning, Patthe result of multiplying with parentheses on the above was always reported an error, but there Dev++was no problem when running on the local one . It was a bit magic...

Guess you like

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