2022年c语言设计谭浩强第三版的课后习题答案.docx
《2022年c语言设计谭浩强第三版的课后习题答案.docx》由会员分享,可在线阅读,更多相关《2022年c语言设计谭浩强第三版的课后习题答案.docx(64页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -c 语言设计谭浩强第三版的课后习题答案 一 (C language design Tan Haoqiang third edition of after-school exercise answers 1 )C language design Tan Haoqiang third edition of after-school Exercises answer 1 1.5, please refer to this chapter example, write a C program, output the
2、following information: The government Very Goodj. The government Solution: main Printf n government; Printf n; Printf Very Good, n; Printf n; Printf *n; 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 1 页,共 45 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - - 1.6 write a program, enter a
3、, B, C three values, the output of which the largest. Solution: Main int, a, B, C, max; Printf enter three numbers a, B, c:n; Scanf %d,%d,%d, &a, &b, &c; Max=a; If maxb Max=b; If maxc Max=c; Printf maximum number:%d, Max; Third chapters 3.3. Please indicate the following numbers in octal and sixteen
4、 第 2 页,共 45 页 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -decimal numbers: 1 10 2, 32 3, 75 4, -617 5 -111 6 2483 7 -28654 8 21003; Solution: eighteen, sixteen 10 = 12 = a 32 = 40 =20 75 = 113 =4b -617 = 176627 =fd97 -111=177621=ff91 2483=
5、4663=963 -28654=110022=9012 21003=51013=520b What is the difference between a 3.5 character constant and a string literal. Solution: a literal constant is a character enclosed in single quotes. String literals are made up of 0 or more characters Instead, wrap them in double quotes and automatically
6、add an 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 3 页,共 45 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -ending symbol 0. to the string at the end of storage 3.6 write down the running results of the following programs: #include Void, main Char, c1=a, c2=b, c3=c, c4=101, c5=116;
7、Printf a%c b%ctc%ctabcn, C1, C2, C3; Printf tb%c%cn, C4, C5; Solution: the result of the program is: AABB CC ABC A N 3.7, China into the password. Password Law: use the original letter after the fourth letters instead of the original letter, For example, the letter A is followed by the fourth letter
8、 E and E instead of A. Therefore, China should be translated as Glmre Please compile a program that uses the initial value agenda to make C1, C2, C3, C4, C5,G,1,m,r,e, and 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 4 页,共 45 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -Output mai
9、n char, c1=, C, c2=, h, c3=, I, c4=n, c5=a; C1+=4; C2+=4; C3+=4; C4+=4; C5+=4; Printf the password is%c%c%c%c%cn, C1, C2, C3, C4, C5; Can the 3.8 case 3.6 be changed as follows.: #include Void, main Int, C1, C2; formerly char, C1, C2 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 5 页,共 45 页 - - - - -
10、 - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -C1=97; C2=98; Printf %c%cn, C1, C2; Printf %d%dn, C1, C2; Solution: Yes, because in the output character range, the use of integer and character type is the same 3.9 find the value of the following arithmetic expression 1 x+a%3* int x+y,%2/4=2.5 x=
11、2.5, a=7, y=4.7 2 float a+b, /2+ int, x% int, y=3.5 a=2, b=3, x=3.5, y=2.5 3.10 write down the running results of the following program: #include Void, main Int, I, J, m, n; I=8; 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 6 页,共 45 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -J=1
12、0; M=+i; N=j+; Printf %d,%d,%d,%dn, I, J, m, n; Results: 9,11,9,10 Fourth chapters 4.4.a=3, b=4, c=5, x=1.2, y=2.4, z=-3.6, u=51274, n=128765, c1=a, c2=b. wanted to To the following output format and results, please write the program requirements output as follows: A= 3, b= 4, c= 5 X=1.200000, y=2.4
13、00000, z=-3.600000 X+y= 3.60, y+z=-1.20, z+x=-2.40 U= 51274 n= 128765 C1=aor 97 ASCII 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 7 页,共 45 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -C2=Bor 98 ASCII Solution: main Int, a, B, c; Long, int, u, n; Float, x, y, z; char c1, c2; a = 3
14、; b = 4; c = 5; x = 1.2; y = 2.4; z = 3.6; d = 51274; n = 128765; c1 = a; c2 = b; printf n; printf a = b =% 2d 2d c =% 2d n, a, b, c; printf x =% 8.6f, y =% 8.6f, z =% 9.6f n , x, y, z; printf x + y =% 5.2f y = z =% 5.2f z + x =% 5.2f n x + y, 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 8 页,共 45 页
15、 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -y + z, z + x; printf d =% 6ld n =% 9ld n, d, n; printf c1 = % c or% d ascii n, c1, c2; printf c2 = % c or% d ascii n , c2, c2; 4.5 请写出下面程序的输出结果 . 结果: 57 5 7 67.856400, -789.123962 67.856400, -789.123962 67.86, 789.12,67.856400, 789.123962
16、,67.856400, -789.123962 6.785640e + 001, -7.89e + 002 a 65101,41 12345674553207, d687 6553517777, ffff, - 1 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 9 页,共 45 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -computer, com 4.6 用下面的 scanf 函数输入数据 , 使 a = 3, b = 7 x = 8.5, y = 71.82, c
17、1 = a, c = a 问在键盘上如何输入 . main int a, b; float x, y; char c1, c2; scanf a =% d b =% d, & a & b; scanf x =% f y =% e , & x & y; scanf c1 = c2 =% c% c, & c1 & c2; 解: 可按如下方式在键盘上输入 : a = 3, b = 7 x = y = 71.82 8.5 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 10 页,共 45 页 - - - - - - - - - 名师归纳总结 精品学习资料 -
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022 语言 设计 谭浩强 第三 课后 习题 答案
限制150内