C language programming exercise: temperature conversion

  We usually talk about Celsius temperature, and foreigners often talk about Fahrenheit temperature. Although the formula is simple: F=C*9/5+32, it is still very difficult to easily convert between talking and laughing. Why not write a program that can automatically convert degrees Celsius Convert it to Fahrenheit.

Input format

  One line, an integer, indicating the temperature in degrees Celsius

Output format

  A decimal, indicating the temperature in Fahrenheit (to two decimal places)

Sample input

0

Sample output

32.00

Data size and convention

  The range of Celsius temperature is [-100,1000]

The code is as follows:

#include

int main ()

{

int c;

float f;

scanf("%d",&c); //Enter Celsius temperature

printf("%.2f",c*9.0/5+32); //Output the temperature in Fahrenheit, .2 means to keep two decimal places

return 0;

}


In addition, if you want to better improve your programming ability, learn C language and C++ programming! Overtaking in a curve, one step faster! I may be able to help you here~

UP has uploaded some video tutorials on learning C/C++ programming on the homepage. Those who are interested or are learning must go and take a look! It will be helpful to you~

Sharing (source code, actual project video, project notes, basic introductory tutorial)

Welcome partners who change careers and learn programming, use more information to learn and grow faster than thinking about it yourself!

Programming learning:

Programming learning:

Guess you like

Origin blog.csdn.net/weixin_45713725/article/details/114927282