c语言第五章答案许合利,c语言程序设计答案贾宗璞许合利

第1章

1选择题

(1) C (2) B (3) D

2填空题

(1)main (2) main (3) 有穷性、确定性、有零个或多个输入、有一个或多个输出、有效性

(4) 顺序、分支和循环(5) 自顶向下,逐步细化、模块化设计、结构化编码

第2章

1选择题

BBCDA DDBBA BBDCB

2、填空题

(1) 数字、字母、下划线 (2)0 (3) 4、8 (4) (a+b)*c/(a-b) (5) -60 6-16

73 86、4、2 90 1010、6 115.500000 12 12、4

13double 14 0 1516 166.6

3、编程题

1

main()

{

printf("int:%5d\n"

"float:%5d\n"

"char:%5d\n"

"double:%5d\n"

"long:%5d\n",

sizeof(int),+-

sizeof(float),

sizeof(char),

sizeof(double),

sizeof(long));

}

2

#define RAT 1.60934

main()

{

float k=0.0;

printf("input the km:");

scanf("%f",&k);

printf("\nmile:%f",k*RAT);

}

第3章

1选择题

(1)~(10):DDCDCDCDBC

2解析题

(1) x=170,x=ㄩㄩㄩ170,x=ㄩㄩㄩ252, x=ㄩㄩㄩ170

x=170,x=170ㄩㄩㄩ,x=ㄩㄩㄩ170,x=%6d a=513.789185,a=ㄩㄩ513.79,a=513.78918457,a=513.78918457

(2) a=3ㄩb=7x=8.5ㄩy=71.82c1=Aㄩc2=a

3编程题

(1)

main()

{

int x,y;

scanf("%d%d",&x,&y);

printf("商数=%d,余数=%d",x/y,x%y);

system("pause");

}

(2)

main()

{

double x,y,z,avg;

scanf("%lf%lf%lf",&x,&y,&z);

avg=(x+y+z)/3;

printf("%.1lf",avg,avg);

system("pause");

}

第4章

1选择题

(1)(10) CCAADCCABD

2填空题

(1) ch>='A' && ch<='Z' ch=ch-32

(2) x<=10 && x>2 x<=2 && x>-1 y=-1

(3) a+b>c && a+c>b && b+c>a a==b&&a==c a==b || a==c || b==c

(4) mark/10 k=1 case 9

(5) x<0 c=x/10 y!=-2

3编程题

(1)

#include

main()

{

int x;

printf("please input a number:");

scanf("%d",&x);

if(x%2==0) printf("x is a even number");

else printf("x is a odd number");

}

(2)

#include

main()

{ int x,y;

printf("please input a numbero");

scanf("%d",&x);

if(x<=-5) printf("the number is error");

else if(x<0) {y=x; printf("%d",y);}

else if(x==0) {y=x-1;printf("%d",y);}

else if(x<10) {y=x+1;printf("%d",y);}

else printf("the number is error");

}

(3)

#include

main()

{ int a,m;

printf("please input a number:");

scanf("%d",&a);

switch(a/10)

{ case 0:

case 1:

case 2:m=1;break;

case 3:m=2;break;

case 4:m=3;break;

case 5:m=4;break;

default:m=5;break;

}

printf("%d",m);

}

(4)

#include

main()

{

float price,tax;

printf("please input the price of product:");

scanf("%f",&price);

if(price>10000) tax=price*0.05;

else if(price>5000) tax=price*0.03;

else if(price>1000) tax=price*0.02;

else tax=0;

printf("%f",tax);

}

(5)

#include

main()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值