3.11编程练习(C Primer Plus 第6版 中文版)

1.

#include<stdio.h>
int main(void)
{
	//整数上溢
	int i = 2147483647;
	unsigned int j = 4294967295;
	printf("%d %d  %d\n", i, i + 1, i + 2);
	printf("%u  %u   %u\n", j, j + 1, j + 2);
	//浮点数上溢
	float k = 3.4E38;
	printf("%f\n", k*100.0f);
	//浮点数下溢
	float c, d;
	c = 1.4E-45;
	d = 1.4E-45 / 2;
	printf("c = %e\n", c);
	printf("d = %e\n", d);
	return(0);
}

2.

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void)
{
	int a;
	printf("please enter an ASCII number:");
	scanf("%d", &a);
	printf("the number %d is %c\n", a,a);
	return(0);
}

3.

#include<stdio.h>
int main(void)
{
	printf("\aStartled 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 a;
	printf("Enter a floating-point value:");
	scanf("%f", &a);
	printf("fixed-point notation:%f\n", a);
	printf("exponential notation:%e\n", a);
	printf("p notation:%a\n", a);
	return(0);
}

5

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void)
{
	int age;
	printf("Please enter your age:");
	scanf("%d", &age);
	printf("the age %d is %fs\n", age, age*3.156e07);
	return(0);
}

6

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void)
{
	int water;
	double  weight;
	printf("请输入水的夸脱数:");
	scanf("%d", &water);
	weight = water * 950 / 3.0e-23;
	printf("the %d water is %e weight",water,weight);
	return(0);
}

7

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void)
{
	float inches;
	float high;
	printf("请输入身高(英寸):");
	scanf("%f", &inches);
	high = 2.54*inches;
	printf("the %f inches is %f high",inches,high);
	return(0);
}

8

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(void)
{
	float cups,pint, ounce, soup_spoon, tea_spoon;
	printf("please enter the cups:");
	scanf("%f", &cups);
	pint = cups/ 2.0;
	ounce = 8.0*cups;
	soup_spoon = 8.0*cups*2.0;
	tea_spoon = 8.0*cups*2.0*3.0;
	printf("%fcups is %fpint\n %founce\n %fsoup_spoon\n %ftea_spoon\n", cups, pint, ounce, soup_spoon, tea_spoon);
	return(0);
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值