ImageVerifierCode 换一换
格式:DOCX , 页数:85 ,大小:42.64KB ,
资源ID:3029759      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3029759.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C语言程序设计现代方法第二版习题答案.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C语言程序设计现代方法第二版习题答案.docx

1、C语言程序设计现代方法第二版习题答案 时磊忖呎 Chapter 2An swers to Selected Exercises2.was #2 (a) The program contains one directive (#inelude) and four statements (three calls of printf and one return).(b)Parkinsons Law:Work expands so as to fill the timeavailable for its completi on.3.was #4#i nclude int main(v oid)int

2、 height = 8, le ngth = 12, width = 10, volume;volume = height * len gth * width;printf(Dimensions: %dx%dx%dn, length, width, height);prin tf(Volume (cubic in ches): %dn, volume);printf(Dimensional weight (pounds): %dn, (volume + 165) / 166);return 0;4.was #6 Heres one possible program:#i nclude int

3、main(v oid)int i, j, k;float x, y, z;prin tf(Value of i: %dn, i);prin tf(Value of j: %dn, j);prin tf(Value of k: %dn, k);prin tf(Value of x: %gn, x);prin tf(Value of y: %gn, y); 时磊忖呎 printf(Value of z: %gn, z);return 0;Whe n compiled using GCC and the n executed, this program produced thefollow ing

4、output:Value of i: 5618848Value of j: 0Value of k: 6844404Value of x: 3.98979e-34Value of y: 9.59105e-39Value of z: 9.59105e-39The values printed depend on many factors, so the chanee that youll get exactly these nu mbers is small.5.was #10 (a) is not legal because 100_bottles beg ins with a digit.8

5、.was #12 There are 14 tokens: a, =, (, 3, *, q, -, p, *, p, ), /, 3,and ;.An swers to Selected Programmi ng Projects4.was #8; modified#i nclude int main(v oid)float orig in al_am ount, amoun t_with_tax;prin tf(E nter an amoun t:);sca nf(%f, &orig in al_am oun t);amoun t_with_tax = orig in al_am ount

6、 * 1.05f;prin tf(With tax added: $%.2fn, amou nt_with_tax);return 0;The amount_with_tax variable is unnecessary. If we remove it, the programis slightly shorter: #i nclude int main(v oid)float orig in al_am ount;prin tf(E nter an amoun t:);sea nf(%f, &orig in al_am oun t);printf(With tax added: $%.2

7、fn, original_amount * 1.05f);return 0;Chapter 3An swers to Selected Exercises2.was #2(a)printf(%8.1e, x);(b)printf(%10.6e, x);(e) pri ntf(%-8.3f, x);(d) printf(%6.0f, x);5.respectively.was #8 The values of x, i, and y will be 12.3, 45, and .6,An swers to Selected Programmi ng Projects1.was #4; modif

8、ied#i nclude int main(v oid)int mon th, day, year;prin tf(E nter a date (mm/dd/yyyy):);sca nf(%d/%d/%d, &mon th, & day, &year);prin tf(You en tered the date %d%.2d%.2dn, year, mon th, day);return 0;3.was #6; modified#i nclude int main(v oid)int prefix, group, publisher, item, check_digit;printf(Ente

9、r ISBN:);sca nf(%d-%d-%d-%d-%d, & prefix, & group, & publisher, & tem, &check_digit);prin tf(GS1 prefix: %dn, prefix);prin tf(Group ide ntifier: %dn, group);prin tf(Publisher code: %dn, publisher);printf(Item number: %dn, item);prin tf(Check digit: %dn, check_digit);/* The five printf calls can be c

10、ombined as follows:printf(GS1 prefix: %dnGroup identifier: %dnPublishercode: %dnItem number: %dnCheck digit: %dn,prefix, group, publisher, item, check_digit);*/return 0;Chapter 4An swers to Selected Exercises2.was #2 Not in C89. Suppose that i is 9 and j is 7. The value of (-i)/j could be either 1 o

11、r 2, depending on the implementation. On the other hand, the value of -(i/j) is always 1, regardless of the implementation.In C99, on the other hand, the value of (-i)/j must be equal to the value of -(i/j).9.was #6(a)63 8(b)3 2 1(c)2 -1 3(d)0 0 0 时磊忖呎 13.was #8 The expressi on +i is equivale nt to

12、(i += 1). The value of both expressi ons is i after the in creme nt has bee n performed.An swers to Selected Programmi ng Projects2. was #4#i nclude int main(v oid)int n;prin tf(E nter a three-digit nu mber:);sca nf(%d, &n);printf(The reversal is: %d%d%dn, n % 10, (n / 10) % 10, n / 100);return 0;Ch

13、apter 5An swers to Selected Exercises2. was #2(a)1(b)1(c)1(d)14.was #4 (i j) - (i j)6.was #12 Yes, the statement is legal. When n is equal to 5, it does nothing, since 5 is not equal to - 9.10.was #16 The output ison etwosince there are no break stateme nts after the cases.An swers to Selected Progr

14、ammi ng Projects 2. was #6#i nclude int main(v oid)int hours, minu tes;prin tf(E nter a 24-hour time:); sca nf(%d:%d, & hours, &min utes);prin tf(Equivale nt 12-hour time:);if (hours = 0)printf(12:%.2d AMn, minutes);else if (hours 12)prin tf(%d:%.2d AMn, hours, mi nutes); else if (hours = 12)prin tf(%d:%.2d PMn, hours, mi nutes); elseprin tf(%d:%.2d PMn, hours - 12, minu tes);return 0;4. was #8; modified#i nclude int main(v oid)int speed;prin tf(E nter a wi nd speed in kno ts:); scanf(%d, &spee

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1