您的位置:首页 > 编程语言 > C语言/C++

【C语言学习】《C Primer Plus》第5章 运算符、表达式和语句

2015-05-18 09:57 561 查看
学习总结

1、有了一定的语言基础,运算符和表达式这些都大同小异,无外乎赋值运算符(=)、算术运算符(+、-、*、/、%、++、——)和其他的一下运算符(sizeof、(type))。

2、声明一个参数就创建了一个被称为形式参数(formal argument)或形式参量(formal parameter)。我们称函数调用传递一个值,这个值被称为实际参数(actual argument)或实际参量(actual parameter)。

3、编程练习(题8):

#include <stdio.h>
void Temperatures(double Fahrenheit);
const double c1=1.8l;
const double c2=32.0l;
const double c3=273.16l;
int main(){
double frh;
while(1){
printf("please enter Fahrenheit:");
scanf("%lf",&frh);
if(frh==0){
break;
}
Temperatures(frh);
frh=0;
}
printf("over!\n");
return 0;
}

void Temperatures(double f){
printf("Fahrenheit=%.2f\n",f);
printf("Celsius=%.2f\n",c1*f+c2);
printf("Kelvin=%.2f\n",c1*f+c2+c3);
}


运行结果:

please enter Fahrenheit:12

Fahrenheit=12.00

Celsius=53.60

Kelvin=326.76

please enter Fahrenheit:q

over!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: