1、第二章 表达式参考答案一、选择题(把正确选项的字母标号填到表格中)题号1234567891011121314151617181920答案ADCBBDBBCCBDBAABAADB- 2 -二、判断题(错的填,对的填)题号1234567891011121314151617181920答案三、应用题1.程序改错题#include #include void main(void)int a, b, c;float s, area;printf(Please enter three sides a,b and c: );scanf(%d%d%d, &a, &b, &c);s = (float)1 / 2
2、 * (a + b + c);area = sqrt(s * (s-a) * (s-b) * (s-c) ;printf(Three sides: a=%d,b=%d,c=%dn,a,b,c);printf(Area=%.1fn,area);2. 写出与以下公式相对于的C语句,变量m,v,b,c均为int型。(1)KinEn = (float)1/2 * m * v * v; 或:#include “math.h” KinEn = (float)1 / 2 * m * pow(v,2);(2)res = (float)(b+c) /(2 * b *c);3. 填写表格根据已知条件计算各表达式的
3、值,并把结果写在表格中。已知条件表达式表达式的值1 / 3 + 11 % 51x=4x+=x+311x=2x%= 52a=1, b=2+a+b+4x=2945x%105x/10%104x/10029x/10/10%109四、编程题1.C语言程序设计(第2版)中第80页第10题。#include int main(void) float x, y, s, p, total;printf(Please enter x: );scanf(%f,&x);printf(Please enter y: );scanf(%f,&y);p = x * y;s = x + y;total = s * s + p * (s - x) * (p + y);printf(total=%fn, total); return 0;