电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

c语言程序设计现代方法(第二版)习题答案

c语言程序设计现代方法(第二版)习题答案_第1页
1/83
c语言程序设计现代方法(第二版)习题答案_第2页
2/83
c语言程序设计现代方法(第二版)习题答案_第3页
3/83
Chapter 2 Answers to Selected Exercises 2. [was #2] (a) The program contains one directive (#include) and four statements (three calls of printf and one return). (b) Parkinson's Law: Work expands so as to fill the time available for its completion. 3. [was #4] #include int main(void) { int height = 8, length = 12, width = 10, volume; volume = height * length * width; printf("Dimensions: %dx%dx%d\n", length, width, height); printf("Volume (cubic inches): %d\n", volume); printf("Dimensional weight (pounds): %d\n", (volume + 165) / 166); return 0; } 4. [was #6] Here's one possible program: #include int main(void) { int i, j, k; float x, y, z; printf("Value of i: %d\n", i); printf("Value of j: %d\n", j); printf("Value of k: %d\n", k); printf("Value of x: %g\n", x); printf("Value of y: %g\n", y); printf("Value of z: %g\n", z); return 0; } When compiled using GCC and then executed, this program produced the following output: Value of i: 5618848 Value of j: 0 Value of k: 6844404 Value of x: 3.98979e-34 Value of y: 9.59105e-39 Value of z: 9.59105e-39 The values printed depend on many factors, so the chance that you'll get exactly these numbers is small. 5. [was #10] (a) is not legal because 100_bottles begins with a digit. 8. [was #12] There are 14 tokens: a, =, (, 3, *, q, -, p, *, p, ), /, 3, and ;. Answ ers to Selected Programming Projects 4. [was #8; modified] #include int main(void) { float original_amount, amount_with_tax; printf("Enter an amount: "); scanf("%f", &original_amount); amount_with_tax = original_amount * 1.05f; printf("With tax added: $%.2f\n", amount_with_tax); return 0; } The amount_with_tax variable is unnecessary. If we remove it, the program i...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

c语言程序设计现代方法(第二版)习题答案

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部