C语言课后****题答案
第一章****题答案
一、选择题
1~5:BDCDA 6~10:DABBB 11~
二、填空题
1、main()
2、函数首部,函数体
3、函数
4、编辑、编译、连接、运行
5、.cpp、.obj、.exe
6、; 或分号
三、编程题
#include <> /* 包含标准库的信息*/
void main() /* 定义名为main 的函数,它不接受参数值*/
{ /* main函数的语句都被括在花括号中*/
printf("hello, world\n");
/* main 函数调用库函数printf 以显示字符序列,其中\n代表换行符*/
}
第二章****题答案
一、选择题
1~5:CBABB 6~10:CDCDD 11~15:CADBC 16~20:BDAAD
二、填空题
1、整型,实型,字符型,枚举类型
2、1
3、9
4、
5、2,1
6、2,2
7、10 20 0
8、a=14
9、2,3,1
10、double
第三章****题答案
一、选择题
1~5:CBBBC 6~10:DDDBB
二、填空题
1、控制语句,表达式语句, 复合语句
2、;
3、{}
4、1
5、a
6、c:dec=120,oct=170,hex=78,ASCII=x
7、32767,32767
8、10,A,10
9、3 3
10、
(1) 123.
(2) □□□□□□□
(3)
(4) 8765.
(5) □□□□□□
(6)
(7)
三、编程题
1、参考答案:
#include <>
void main()
{
int a,b,c;
long int u,n;
float x,y,z;
char c1,c2;
a=3;b=4;c=5;
x=;y=;z=-;
u=51274;n=;
c1='a';c2='b';
printf("\n");
printf("a=%2d b=%2d c=%2d\n",a,b,c);
printf("x=%,y=%,z=%\n",x,y,z);
printf("x+y=% y+z=% z+x=%\n",x+y,y+z,z+x);
printf("u=%6ld n=%9ld\n",u,n);
printf("c1='%c' or %d(ASCII)\n",c1,c1);
printf("c2='%c' or %d(ASCII)\n",c2,c2);
}
2、参考答案:
#include <>
void main()
{
float a, b, c, t;
printf("please input a,b,c:\n");
scanf ("%f, %f, %f", &a, &b, &c);
t=(a+b+c)/3;
printf ("average of %、% and % is %\n",a,b,c,t);
}
3、参考答案:
#include <>
main()
{
int R, d;
float s;
printf("请输入圆的半径");
scanf("%d",&R);
d=2*R;
c=2**R;
printf("d=%d,c=%f\n",d,c);
}
4、参考答案:
#include <>
void main()
{
int h, f, x, y; /* x为鸡的数量,y为兔的数量*/
printf("请输入鸡兔的总头数h,总脚数 f:");
scanf("%d%d", &h, &f);
x=(4*h-f)/2;
y=(f-2*h)/2;
printf("笼中有鸡%d 只,有兔%d只。\n", x, y);
}
第四章****题答案
一、选择题
CDDDD CDBBC
二、填空题
1、&&, || , !, ! , | |
2、(y%2 0)
3、1
4、(a+b>c&&a+c>b&&b+c>a)
5、2 3 3
6、7
三、编程题
1、参考答案:
#include <stdi
C语言课后习题答案 来自淘豆网www.taodocs.com转载请标明出处.