C primer plus (第6版)中文版 第三章答案

//第 1 题

#include <stdio.h>
#include <float.h>
#include <limits.h>
int main(void)
{
	int big_int = 2147483647;
	float big_float = 3.4e38;
	float small_float = 10.0 / 3;
	printf("The big int data is %d\n", big_int + 1);
	printf("The big float data is %f\n", big_float * 10);
	printf("The big float data is %f\n", small_float);
	printf("The MAX float data is %f\n", FLT_MAX);
	printf("The MAX int data is %ld\n", INT_MAX);
	return 0;
}
//第 2 题

#include <stdio.h>
int main(void)
{
	int input;
	printf("Enter a value of char int ASCII:");
	scanf("%d", &input);
	printf("You input value is %d,and char is %c\n", input, input);
	return 0;
}
//第 3 题

#include <stdio.h>
int main(void)
{
	char ch = '\a';
	printf("%c", ch);
	printf("Starled by the sudden sound, Sally shouted, \n");
	printf("\"By the Great Pumpkin, what was that!\"\n");
	return 0;
}
//第 4 题

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	float input;
	printf("Enter a floating-point value.");
		scanf("%f", &input);
	printf("fixed-point notation: %f \n", input);
	printf("exponential notation: %e \n", input);
	printf("p notation: %a \n", input);
	return 0;
}
//第 5 题

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define SEC_PER_YEAR 3.156e7
int main(void)
{
	float second, year;
	printf("Enter how many years old you are:");
	scanf("%f", &year);
	second = year * SEC_PER_YEAR;
	printf("You are: %.1f years old.\n", year);
	printf("And you are %e seconds old, too.\n", second);
	return 0;
}
//第 6 题

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define MASS_PER_MOLE 3.0e-23
#define MASS_PER_QUART 950
int main(void)
{
	float quart, quantity;
	printf("Enter how many quart:");
	scanf("%f", &quart);
	quantity = quart * MASS_PER_QUART / MASS_PER_MOLE;
	printf("There are %e molecule.\n", quantity);
	return 0;
}
//第 7 题

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define INCH_TO_CM 2.54
int main(void)
{
	float inch, cm;
	printf("Enter the inch of your heigh:");
	scanf("%f",&inch);
	cm = inch * INCH_TO_CM;
	printf("Hi ,your are %0.2f inch ,or 8.2f cm heigh\n", inch, cm);
	return 0;
}
//第 8 题

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define PINT_CUP 2
#define CUP_OUNCE 8
#define OUNCE_SPOON 2
#define SPOON_TEA 3
int main(void)
{
	float pint, cup, ounce, spoon, tea_spoon;
	printf("Enter how many cup:");
	scanf("%f", &cup);
	pint = cup / PINT_CUP;
	ounce = cup * CUP_OUNCE;
	spoon = ounce * OUNCE_SPOON;
	tea_spoon = spoon * SPOON_TEA;
	printf("%.1f cup equals %.1f pint, %.1f ounce, %.1f spoon, %.1f tea spoon. \n",
		cup, pint, ounce, spoon, tea_spoon);
	return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值