C Primer Plus第六版第三章复习题答案

  1. a. unsigned int
    b. float
    c. char
    d. unsigned int
  2. 当系统中int的大小和long的大小相同时,使用int时应该改为long(可提高移植性),或者是当数据超过int的表数范围的时候应使用long

3.int32_t,确保在不同的系统中不会出现错误
4.
a.char backspace
b.int 数字1066
c.double 数字99.44
d.注意:unsigned int 十六进制常量
e.double 数字2.0x10的30次方
5.修改后的程序如下:

#include <stdio.h>
int main(void)
{
	float g,h;
	float tax,rate;
	g = .3e21;//注意,小数点和E可以省略一个不能同时省略,整数部分和小数部分可以省略一个但不能同时省略
	tax = rate * g;
}

常量 类型 转换说明(%转换字符)
12 int %d
OX3 unsigned int %#X
‘C’ char %c
2.34E07 double %e
‘\040’ char %c
7.0 double %f
6L long %ld
6.0f float %f
0x5.b6p12 double %a
常量 类型 转换说明(%转换字符)
012 unsigned int %#o
2.9e05L long double %le
‘s’ char %c
100000 int %d
‘\n’ char %c
20.0f float %f
0x44 unsigned int %#x
-40 int %d
//补充后的printf()
printf("The odds against the %d were %ld to 1.\n", imate, short);
printf("A score of %f is not an %c grade.\n", log, grade);
char ch;
=ch = '\r';//转移序列
ch = 13;//十进制
ch = 015;//八进制
ch = 0x0D;//十六进制

10.修改后的程序如下:

#include<stdio.h>
int main(void)	/*this program is perfect*/
{
	int cows, legs;
	
	printf("How many cow legs did you count?\n");
	scanf("%d", &legs);
	cows = legs/4;
	printf("That implies there are %d cows.\n", cows);

	return 0;
 
}

a.\n newline
b.\\ backflash
c." double quotes
d.\t horizontal tab

猜你喜欢

转载自blog.csdn.net/weixin_42912350/article/details/82020117