C语言编写华氏温度计和摄氏温度及的转换

 时间:2024-10-12 18:20:39

1、首先打开VC++

C语言编写华氏温度计和摄氏温度及的转换

2、文件》》新建

C语言编写华氏温度计和摄氏温度及的转换

3、新建一个C++文档

C语言编写华氏温度计和摄氏温度及的转换

4、声明头文件和变量#include<stdio.h>char cmd;float temperature;

C语言编写华氏温度计和摄氏温度及的转换

5、主要代码,先进行选择,是蹰虞吃遂华氏还是摄氏,然后用公式转化while(1){printf("\n******************忮氽阝另***********************\n");printf("\n| Please select one of convertions: |\n"); printf("| c: Convert Celsius to Fahrenheit |\n");printf("| f: Convert Fahrenheit to Celsius |\n");printf("| q: Quit |\n");printf("\n*****************************************\n");scanf("%c",&cmd);switch (cmd){case 'c':{printf("\n*****************************************\n");printf("\n| Please input Celsius temperature: |\n");scanf("%f",&temperature);printf("\n| The Fahrenheit temperature is:%6.3f|\n",temperature*1.8+32);printf("\n*****************************************\n");break;}case 'f':{printf("\n*****************************************\n");printf("\n Please input Fahrenheit temperature: |\n");scanf("%f",&temperature);printf("\n The Celsius temperature is : %6.3f |\n",5*(temperature-32)/9);printf("\n*****************************************\n");break;}case 'q':{break;}default:{printf("Your Command Error!temperatureut Again\n");}}getchar();if(cmd=='q')break;printf("\n Please input any key to use again: \n");getchar();}return 0;

C语言编写华氏温度计和摄氏温度及的转换C语言编写华氏温度计和摄氏温度及的转换

6、运行结果

C语言编写华氏温度计和摄氏温度及的转换
  • 自定义函数查找子串怎样用C++实现
  • Android 安装apk包的五种方式
  • 怎样才能延迟开学
  • 如何解决Code::Blocks编译时报错
  • Python例子-统计字符串中,各个字符的个数
  • 热门搜索
    怎么查养老保险缴费情况 切完辣椒后手很辣怎么办 睾怎么读 说明书怎么写 美图秀秀怎么加水印 房贷利息怎么算 无线网卡驱动怎么安装 低血压高怎么办 痱子怎么消除 怎么创建苹果id