Exercise 2-8 of Zhejiang University Edition "C Language Programming (3rd Edition)"

Exercise 2-8 Calculate 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. Calculation formula: C=5×(F−32)/9. The question guarantees that the input and output are within the integer range.
Input format:
Input gives a temperature in Fahrenheit in one line.
Output format:
output the corresponding integer value of Celsius temperature C in one line according to the format "Celsius = C".
Input sample:
150
Output sample:
Celsius = 65
Author
Chen Jianhai
Unit
Zhejiang University

Code length limit
16 KB
Time limit
400 ms
Memory limit
64 MB

#include <stdio.h>

int main() {
    
    
    int Celsius;
    if (scanf("%d", &Celsius) == 1) {
    
    
        printf("Celsius = %d", 5 * (Celsius - 32) / 9);
    }
    return 0;
}

Guess you like

Origin blog.csdn.net/DoMoreSpeakLess/article/details/109249245