《C Primer Plus》(第6版)中文版 课后练习题 - Chapter 3

这章难点在于参数类型的定义。
practise 2 ______________ #include <stdio.h> int main(void) { int number; printf("请输入一个ASCII码值:"); scanf("%d",&number); //获取输入值 printf("输入的ASCII码值 %d.\n",number); return 0; }

  

practise 3
______________
#include <stdio.h>
int main(void)
{
//	printf("\007\n");//发出警报 
	printf("\a\n") ;//也是发出警报 
	printf("Startled by the sudden sound,Sally shouted,\n");
	printf("By the Great Pumpkin,what was that!");
	
	return 0;
}

  

practise 4
______________
#include <stdio.h>
int main(void)
{
	float number;
	printf("Enter a floating-point value:\n");//提升进行数值输入 
	scanf("%f",&number);//获取输入 
	printf("fixed-point notation:%f\n",number);//小数点形式 
	printf("exponential notation:%e\n",number);//指数形式 
	printf("p notation:%a",number);//p计数法 ,打印用a,不是p。 
	
	return 0;
 } 

  

practise 5
______________
#include <stdio.h> 
int main(void)
{
	float age,age_second;//定义参数类型 
	printf("Enter your really age:\n") ;//提示输入 
	scanf("%f",&age);//获取输入 
	age_second = 3.156e7*age;//年换算成秒 
	printf("the total second in your age is %e\n",age_second);//打印用指数e,便于看 
	return 0;
}

  

practise 6
______________
#include <stdio.h>
int main(void)
{
	float water_kuatuo,water_nuclear;
	printf("Enter the quality of water:\n");//提示输入水的夸脱数 
	scanf("%f",&water_kuatuo);// 获取输入 
	water_nuclear = water_kuatuo*950/3.0e-23;
	printf("The number of water nuclear is %e",water_nuclear);//删除总分子数 
	return 0;
 } 

  

practise 8
______________
#include <stdio.h>
int main(void)
{
	float cup,pint,ounce,ladle,spoon;//杯,品脱,盎司,汤勺,茶勺
	printf("Enter the number of cup:\n");//提示输入 
	scanf("%f",&cup);//获取输入 
	pint  = cup/2;//一品脱等于2杯 
	ounce = cup*8;//一杯等于8盎司 
	ladle = ounce*2;//一盎司等于2大勺 
	spoon = ladle*3; //一大勺等于3茶勺
	printf("The number of water in pint is %f.\n",pint); //水换算成品脱的数量 
	printf("The number of water in ounce is %f.\n",ounce);//水换算成盎司的数量 
	printf("The number of water in ladle is %f.\n",ladle);//水换算成汤勺的数量 
	printf("The number of water in spoon is %f.\n",spoon);//水换算成茶勺的数量 
	
	return 0;
}

  

#include <stdio.h> int main(void) { float height_inch,height_cm; printf("Enter your height_inch:\n");//提示输入 scanf("%f",&height_inch);//获取输入 height_cm = height_inch*2.54; printf("your height is %e cm.",height_cm);//输出 return 0;//结束 }

  

数据类型转换符

猜你喜欢

转载自www.cnblogs.com/dachaozi/p/12759231.html
今日推荐