C语言设计(第五版)第三章课后题

#include<stdio.h>
#include<math.h>

Q1:

#if 1
int main() {
	float r = 0.07,y = 10,p;
	p = pow(1 + r, y);
	printf("%f", p);
}
#endif

Q2:

#if 1
int main() {
	float r,p;
	int n;
	p = 1000 * (1 + n * r);//一次五年期
	p = 1000 * (1 + 2 * r);
	p = p * (1 + 3 * r);//先两年后三年
	p = 1000 * pow((1 + r),n);//一年期
	p = 1000 * pow((1 + (r / 4)), 4 * n);//活期一季度结算一次
	return 0;
}
#endif

Q3:

m = log(p / (p - (d * r))) / log(1 + r);

Q4:
1)a,b 97,98;ascll码
2)一些特殊符号…
3)和1)问是一样的结果

Q5:

a=3b=7
8.5 71.82
65 97

Q6:

#if 1
int main(void)
{
	char a, b, c, d, e;
	a = 'C';
	b = 'h';
	c = 'i';
	d = 'n';
	e = 'a';
	//printf("%c%c%c%c%c", a + 4, b + 4, c + 4, d + 4, e + 4);
	putchar(a + 4);
	putchar(b + 4);
	putchar(c + 4);
	putchar(d + 4);
	putchar(e + 4);
}
#endif

Q7:

#if 1
int main(void)
{
	float s,r,h;
	s = PI * r * 2;
	s = PI * pow(r, 2);
	s = 4 * PI * pow(r, 2);
	s = 3 / 4 * PI * pow(r, 3);
	s = PI * pow(r, 2) * h;
}
#endif

Q8:

#if 1
int main(void)
{
	char c1, c2;
	c1 = getchar();
	c2 = getchar();

	putchar(c1);
	putchar(c2);
	putchar('\n');
	printf("%d",c1);
	printf("%d",c2);
}
#endif

1)二者皆可;
2)printf函数,以%d格式输出;
3)不可以,位数不一样,存储数据的大小也不一样,很容易导致出错或数据溢出。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值