- 235
- 0
- 约7.3万字
- 约 197页
- 2021-02-28 发布于山东
- 举报
语言程序设计现代方法习题答案
Chapter 2
Answers to Selected Exercises
[was #2] (a) The program contains one directive (#include) and four statements (three calls of printf and one return).
(b)
Parkinsons Law:
Work expands so as to fill the time
available for its completion.
[was #4] #include stdio.h
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;
}
[was #6] Heres one possible program: #include stdio.h
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 youll get exactly these numbers is small.
[was #10] (a) is not legal because 100_bottles begins with a digit.
[was #12] There are 14 tokens: a, =, (, 3, *, q, -, p, *, p, ), /, 3, and ;.
Answers to Selected Programming Projects
[was #8; modified] #include stdio.h
int main(void)
{
float original_amount, amount_with_tax;
printf(Enter an amount: );
scanf(%f, original_amount);
amount_with_tax = original_amount * ;
printf(With tax added: $%\n, amount_with_tax);
语言程序设计现代方法习题答案
return 0;
}
The amount_with_tax variable is unnecessary. If we remove
it, the program is slightly shorter:
#include stdio.h
int main(void)
{
float original_amount;
printf(Enter an amount: );
scanf(%f, original_amount);
printf(With tax added: $%\n, original_amount * );
return 0;
}
语言程序设计现代方法习题答案
Chapter 3
Answers to Selected Exercises
2. [was #2]
printf(
您可能关注的文档
最近下载
- 应用文写作求职信.pptx VIP
- 注册安全工程师考试《安全生产专业实务(其他安全)》题库(案例分析题)10211.pdf VIP
- 安徽单招考试2025、2025分类考试真题语文数学英语试题(含答案).pdf VIP
- 41834马工程西方文学理论全套PPT课件.pptx
- 粉尘涉爆安全教育课件.ppt VIP
- 协同治理机制经典文献推荐.docx VIP
- 1.国家电力投资集团有限公司光伏项目工程建设管理标准化工作手册.docx VIP
- CECS246-2008 给水排水工程顶管技术规程.pdf VIP
- 人教版(2024)七年级下册英语 Unit 6 Rain or Shine 教案(单元整体教学设计).docx
- 2025年苏州农业职业技术学院单招笔试英语试题库含答案解析.docx VIP
原创力文档

文档评论(0)