



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- DB61T 856-2014 小麦 西农318规范
- DB61T 832-2014 油菜 秦荣4号规范
- DB61T 812-2014 玉米 陕科9号规范
- 中国儿童急性早幼粒细胞白血病诊断与治疗指南
- 墙纸墙布销售合同(标准版)
- 慢病培训课件下载
- 2021年半导体行业研究报告
- 建筑工地人员安全培训与考核方案
- 10kV架空线路施工组织与管理方案
- 城中村改造施工现场防火管理方案
- DB61∕T 1576-2022 矩形钢管混凝土组合桁梁桥技术规范
- 2025-2026学年人教版(2024)初中生物八年级上册(全册)教学设计(附目录)
- 2025-2030中国汽车工程服务外包(ESO)行业现状调查与前景趋势研究报告
- 职业中学数学课件学习方法
- 2025年中国药用菌行业投资前景及策略咨询研究报告
- 软陶教学课件
- 2025年黑吉辽蒙高考化学试卷真题解读及答案详解(精校打印)
- 美术教育学新编
- TCDSA 201.22-2024 呼吸气体质量分析仪
- 特种设备重大事故隐患判定准则试题及答案
- 二年级语文(统编版)二年级上册学习导引课课件
评论
0/150
提交评论