c语言温度转换
❶ c语言编译的,华氏温度转换摄氏温度的程序
while语句上面的花括号,应该在while语句下面的。另外celsius定义为float型好些。celsius=5*(fahr-32)/9;改为:celsius=5*(fahr-32)/9.0;
❷ C语言,华氏温度与摄氏温度的转换
因为你定义的变量是float类型,而如果输入5和9的话,电脑会认为是两个整形数据先相除,然后再转换成float型,所以就变成0了。
❸ c语言编程中怎么将华氏温度转换成摄氏温度
代码如下:
#include <stdio.h>
void main()
{
float F,C;
printf("请输入您需要转换的华氏温度:");
scanf("%f",&F);
C = (F-32)*5/9.0;
printf("其对应的摄氏温度为:%.2f ",C);
}
❹ C语言编程:输入一个华氏温度,要求输出摄氏温度,公式为:
#include<stdio.h>intmain(){doublec,f;printf("请输入华氏温度:");scanf("%lf",&f);c=5.0/9*(f-32);printf("%g华氏温度是%.2f摄氏温度 ",f,c);return0;}
#include<iostream>
using namespace std;
int main()
{
float f,c;
cout<<"请输入华氏温度:";
cin>>f;
c=5*(f-32)/9;
cout<<"摄氏温度为:"<<c<<endl;
return 0;
}
❺ c语言编程,温度转换
#include<stdio.h>
int main()
{
int c;
float f;
scanf("%d",&c); //输入摄氏温度
printf("%.2f",c*9.0/5+32); //输出华氏温度, .2表示保留两位小数
return 0;
}
❻ c语言华氏摄氏温度转换
#include
int
main()
{
float
c,f;
printf("请输入摄氏温度值:\n");
scanf("%f",&c);
//
接收数据错误
scanf("%f,&c\n");
f=32+c*1.8;
printf("摄氏温度=%.2f,转换为华内氏温度=%.2f\n",c,f);
//
输出错容误
转换为华氏温度=&.2f
getch();
return
0;
}
❼ c语言程序设计 温度转换
#include<stdio.h>
intmain()
{intd;
floatt,t1;
printf("确定要转换的类型: 1)华氏转摄氏 ");
printf("2)摄氏转华氏 请选择1或2:");
scanf("%d",&d);
printf("请输专入温度:");
scanf("%f",&t);
if(d==1)
{t1=(t-32)*5/9;
printf("摄氏温度为属%.2f度 ",t1);
}
else
{t1=t*9/5+32;
printf("华氏温度为%.2f度 ",t1);
}
return0;
}
❽ c语言程序设计 温度转换
程序如下:
#include<stdio.h>
void
main()
{
int
n;
float
F,C;
printf("(1)华氏转摄氏\n(2)摄氏转华氏\n");
printf("输入你的选择:\n");
scanf("%d",&n);
if(1==n)
{
printf("输入一个华氏摄氏度数的温度值:\n");
scanf("%f",&F);
C=(F-32)*5/9;
printf("结果是:
%.2f\n",C);
}
if(2==n)
{
printf("输入一个摄氏度数的温度值:\n");
scanf("%f",&C);
F=(C*9/5)+32;
printf("结果是:
%.2f\n",F);
}
}
有疑问提出。
望点赞哦~~
❾ C语言:编写摄氏温度、华氏温度转换程序,怎么写
#include<stdio.h>
voidmain()
{
floatF,C;
printf("请输入您需要转换的摄氏温度:");
scanf("%f",&C);
F=(C+32)*9/5.0;
printf("其对应的华氏温度为:%.2f ",F);
}main()
{
floatC,F;
scanf("%f",&F);
C=5.0/9*(F-32);
printf("%8.2f",C);
}#include<stdio.h>
intmain(void)
{
floatc;
printf("请输入摄氏度:");
scanf("%f",&c);
printf("对应的华氏度:%.2f ",(c+92)*9/5);
return0;
}
❿ c语言编程,温度转换
#include<stdio.h>
int
main()
{
int
c;
float
f;
scanf("%d",&c);
//输入摄氏温度
printf("%.2f",c*9.0/5+32);
//输出华氏温度,
.2表示保留版两位小数权
return
0;
}