C Primer plus第3章练习程序示例

//练习2
# include <stdio.h>
int main(void)
{
	int n;
	
	
	printf("请输入一个ASCII码值:__\b\b");
	scanf("%d",&n);
	printf("%d所代表的ASCII码是%c",n,n);
	
	
	return 0;
 } 
//练习3
 # include <stdio.h>
 int main(void)
 {
 	printf("\aStartled by the sudden sound ,Sally shouted,\n\"By the Great Pupkin, what was that!\"");
 	
 	
 	return 0;
} 
//练习4
# include <stdio.h>
int main(void)
{
	float n;
	
	
	printf("Enter a floating-point value:__\b\b");
	scanf("%f",&n);
	printf("fixes-point notation: %f \n",n);
	printf("exponential notation: %e \n",n);
	printf("p notation %#x \n",n);
	
	
	return 0;
 } 
//练习5
# include <stdio.h>
int main(void)
{
	int n;
	double m;
	
	printf("请输入您的年龄:__\b\b");
	scanf("%d",&n);
	m = n*3.146e7;
	printf("您已经活了%e岁",m);
	
	
	return 0;
 } 
//练习6
# include <stdio.h>
int main(void)
{
	int n;
	double m;
	
	
	printf("请输入水的夸克数:__\b\b");
	scanf("%d",&n);
	m = n*(950/3.0E-23);
	printf("%d夸克水有%d个水分子",n,m);
	
	
	return 0;
}`//练习7
# include <stdio.h>
int main(void)
{
	
	float m,n;
	
	
	printf("请输入您的身高(英寸):__\b\b");
	scanf("%f",&m);
	n = m*2.54;
	printf("您的身高是%fCM",n);
	
	
	return 0;
}`
//练习8
# include <stdio.h>
int main(void) 
{
	 int n;
	 float p,a,d,c;
	 
	 printf("请输入杯数:_\b");
	 scanf("%d",&n);
	 p = 0.5*n;
	 a = 8*n;
	 d = a*2;
	 c = d*3;
	 printf("%d杯等价于%f品脱%f盎司%f大汤勺%f茶勺。",n,p,a,d,c);
	 
	 
	 return 0;
	 
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值