2004 级信息学院《C 语言设计》考试试题 一、判断下列语句或程序的对错
10 分 √ 1 int x=y=z=’0’; (×) y,z 没有定义 2 #include ; (×) 不能有分号,#开头的结尾均不能有分号; 3 printf(“%s\n”,”c language”); (√) 4 float a[100]; int *p=a; (×) 数据类型不匹配 5 char str[20]; 6 int data[4]={0,1,2,3,4}; (×)五个元素,但是只有四个单元 7 float x=1
45e+310L; (×)数值越界 8 int xyz-1=2; (×) 9 int x=‘\xae’ ; (√) 10 int *p,a[2][3] ; p=a ; (×) 数据类型不匹配 二 计算下列表达式的值 10 分 设 unsigned int a=10,b=17,c=5,d=3; float f ; (1)f=b/c ( 3
0 ) (2)
(a+b)+c-1&&b+c/2 ( 1 ) (3)(a^b)+(c>>1+d) ( 0x1b ) (4)a+=b%=a=b ( 17 ) (5)a=2,b=a*++b ( 2 ) 三 程序改错 10 分 (1) 求两个浮点数的平方和及平方差 #include float calculate (float x,float y,float *sub);添加函数原型声明 main () { float a,b; float add_reasult, sub_result; scanf (“%f,%f”,a,b); add_result=calculate(a,b,&sub_result); printf( “a*a+b*b=%d,a*a-b*b=%d\n”,add_result,sub_result); } float c