C Primer Plus编程练习答案(Chapter3)

3.11.1

/*存疑*/

#include<stdio.h>
int main() {
	int overflow_int = 32767;
	float overflow_above_float =  3.4e36;
	float overflow_below_float = -3.4e36;
	printf("整数上溢的情况是%d", overflow_int + 1);
	printf("浮点数上溢的情况是%f", overflow_above_float * 10000.0);
	printf("浮点数下溢的情况是%f", overflow_below_float / 10000.0);
}

3.11.2

#include<stdio.h>
int main() {
	char ch;
	int num;
	printf("请输入任意数字:");
	scanf_s("%d", &num);
	ch = num;
	printf("ASCII %d = %c",num,ch);
}

3.11.3

#include<stdio.h>
int main() {
	printf("\a");
	printf("Startled by the sudden sound, Sally shouted,\n");
	printf("\"By the Great Pumpkin, What was that!\"");
}

3.11.4

#include<stdio.h>
int main() {
	float num;
	printf("Enter a floating-point value:");
	scanf_s("%f", &num);
	printf("fixed-pointed notation:%f \n", num);
	printf("exponential notation:%e \n", num);
	printf("p notation:%.2a \n", num);
}

3.11.5

#include<stdio.h>
int main() {
	float year,second_year = 3.156e7;
	printf("请输入您的年龄:");
	scanf_s("%f", &year);
	printf("您已经活了%f秒了", second_year * year);
}

3.11.6

#include<stdio.h>
int main() {
	float water_quality = 3.0e-23;
	float quart;
	printf("请输入水的夸脱数:");
	scanf_s("%f", &quart);
	printf("水的质量是:%eg", quart * 950 / water_quality);
}

3.11.7

#include<stdio.h>
int main() {
	float height;
	printf("请输入您的身高(英寸):");
	scanf_s("%f", &height);
	printf("您的身高是%.2fcm", height * 2.54);
}

3.11.8

#include<stdio.h>
int main() {
	float cup;
	printf("请输入您的杯数:");
	scanf_s("%f", &cup);

	printf("品脱数为:%.0f\n", cup * 2);
	printf("盎司数为: %.0f\n", cup * 2 * 8);
	printf("汤匙数为: %.0f\n", cup * 2 * 8 * 2);
	printf("茶匙数为: %.0f\n", cup * 2 * 8 * 2 * 3);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值