全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Chapter 8Answers to Selected Exercises1.was #4 The problem withsizeof(a)/sizeof(t)is that it cant easily be checked for correctness by someone reading the program. (The reader would have to locate the declaration ofaand make sure that its elements have typet.)2.was #8 To use a digitd(in character form) as a subscript into the arraya, we would writead-0. This assumes that digits have consecutive codes in the underlying character set, which is true of ASCII and other popular character sets.7.was #10const int segments107 = 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1;Answers to Selected Programming Projects2.was #2#include int main(void) int digit_count10 = 0; int digit; long n; printf(Enter a number: ); scanf(%ld, &n); while (n 0) digit = n % 10; digit_countdigit+; n /= 10; printf (Digit: ); for (digit = 0; digit = 9; digit+) printf(%3d, digit); printf(nOccurrences:); for (digit = 0; digit = 9; digit+) printf(%3d, digit_countdigit); printf(n); return 0;5.was #6#include #define NUM_RATES (int) (sizeof(value) / sizeof(value0)#define INITIAL_BALANCE 100.00int main(void) int i, low_rate, month, num_years, year; double value5; printf(Enter interest rate: ); scanf(%d, &low_rate); printf(Enter number of years: ); scanf(%d, &num_years); printf(nYears); for (i = 0; i NUM_RATES; i+) printf(%6d%, low_rate + i); valuei = INITIAL_BALANCE; printf(n); for (year = 1; year = num_years; year+) printf(%3d , year); for (i = 0; i NUM_RATES; i+) for (month = 1; month = 12; month+) valuei += (double) (low_rate + i) / 12) / 100.0 * valuei; printf(%7.2f, valuei); printf(n); return 0;8.was #12#include #define NUM_QUIZZES 5#define NUM_STUDENTS 5int main(void) int gradesNUM_STUDENTSNUM_QUIZZES; int high, low, quiz, student, total; for (student = 0; student NUM_STUDENTS; student+) printf(Enter grades for student %d: , student + 1); for (quiz = 0; quiz NUM_QUIZZES; quiz+) scanf(%d, &gradesstudentquiz); printf(nStudent Total Averagen); for (student = 0; student NUM_STUDENTS; student+) printf(%4d , student + 1); total = 0; for (quiz = 0; quiz NUM_QUIZZES; quiz+) total += gradesstudentquiz; printf(%3d %3dn, total, total / NUM_QUIZZES); printf(nQuiz Average High Lown); for (quiz = 0; quiz NUM_QUIZZES; quiz+) printf(%3d , quiz + 1); total = 0; high = 0; low = 100; for (student = 0; student high) high = gradess
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电脑销售合同
- 编织艺术面试题及答案
- 福建农信社笔试题及答案
- 2025年江西生物中考试题及答案
- 商品采购合同合同
- 北京护士面试题及答案
- 保山医疗面试题及答案
- 保安面试题及答案
- 签署大小合同
- 库存管理合同
- 景区游客中心培训知识课件
- 2025年钻孔工程钻探工程施工组织设计方案书
- 广西贵百河联考2025-2026学年高一上学期10月月考语文试卷
- 人工智能导论 课件 第2章 人工智能基础
- 2025年职业技能鉴定考试质量督导员测试题及答案
- 2025小学五年级英语句型转换专项卷
- 法律职业资格考试客观题(试卷一)试卷与参考答案(2025年)
- 2026中国大唐集团有限公司校园招聘备考考试题库附答案解析
- 2025年新高考一卷数学试卷及答案
- 慢阻肺健康管理培训课件
- 2025年北京公共交通控股集团有限公司招聘笔试备考试题及答案详解(全优)
评论
0/150
提交评论