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

更新时间:2023-05-14 01:56:51 阅读: 评论:0

c语言程序设计现代方法(第二版)习题答案(5篇)
第一篇:c语言程序设计现代方法(第二版)习题答案
Chapter 2 Answers to Selected Exercis 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%dn”, length, width, height);printf(“Volume(cubic inches): %dn”, volume);printf(“Dimensional weight(pounds): %dn”,(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: %dn”, i);printf(“Value of j: %dn”, j);printf(“Value of k: %dn”, k);
printf(“Value of x: %gn”, x);printf(“Value of y: %gn”, y);printf(“Value of z: %gn”, 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 the numbers is small.5.[was #10](a)is not legal becau 100_bottles begins with a digit.8.[was #12] There are 14 tokens: a, =,(, 3, *, q,-, p, *, p,), /, 3, and;.Answers 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: $%.2fn”, amount_with_tax);
return 0;} The amount_with_tax variable is unnecessary.If we remove it, the program is slightly shorter: #include
int main(void){ float original_amount;
printf(“Enter an amount: ”);scanf(“%f”, &original_amount);printf(“With tax added: $%.2fn”, original_amount * 1.05f);
return 0;}
Chapter 3 Answers to Selected Exercis 2.[was #2](a)printf(“%-8.1e”, x);(b)printf(“%10.6e”, x);(c)printf(“%-8.3f”, x);(d)printf(“%6.0f”, x);5.[was #8] The values of x, i, and y will be 12.3, 45, and.6, respectively.Answers to Selected Programming Projects 1.[was #4;modified] #include
怎么养蚯蚓int main(void){ int month, day, year;
printf(“Enter a date(mm/dd/yyyy): ”);scanf(“%d/%d/%d”, &month, &day, &year);printf(“You entered the date %d%.2d%.2dn”, year, month, day);
return 0;} 3.[was #6;modified] #include
int main(void){ int prefix, group, publisher, item, check_digit;
家乡变化
适合中学生看的电影printf(“Enter ISBN: ”);scanf(“%d-%d-%d-%d-%d”, &prefix, &group, &publisher, &item, &check_digit);
printf(“GS1 prefix: %dn”, prefix);printf(“Group identifier: %dn”, group);printf(“Publisher code: %dn”, publisher);printf(“Item number: %dn”, item);printf(“Check digit: %dn”, check_digit);
/* The five printf calls can be combined as follows:
施耐淹printf(“GS1 prefix: %dnGroup identifier: %dnPublisher code: %dnItem number: %dnCheck digit: %dn”, prefix, group, publisher, item, check_digit);*/
return 0;}顺利的反义词
Chapter 4 Answers to Selected Exercis 2.[was #2] Not in C89.Suppo that i is 9 and j is 7.The value of(-i)/j could be either –1 or –2, depending on the implementation.On the ot
her 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 expression ++i is equivalent to(i += 1).The value of both expressions is i after the increment has been performed.Answers to Selected Programming Projects 2.[was #4] #include
int main(void){ int n;
printf(“Enter a three-digit number: ”);scanf(“%d”, &n);printf(“The reversal is: %d%d%dn”, n % 10,(n / 10)% 10, n / 100);
return 0;}
Chapter 5 Answers to Selected Exercis 2.[was #2](a)1(b)1(c)1(d)1 4.[was #4](i > j)12, minutes);
return 0;} 4.[was #8;modified] #include
int main(void){ int speed;
前方高能什么意思
printf(“Enter a wind speed in knots: ”);scanf(“%d”, &speed);
if(speed < 1)printf(“Calmn”);el if(speed <= 3)printf(“Light airn”);el if(speed <= 27)printf(“Breezen”);el if(speed <= 47)printf(“Galen”);el if(speed <= 63)printf(“Stormn”);el printf(“Hurricanen”);
return 0;} 6.[was #10] #include
int main(void){ int check_digit, d, i1, i2, i3, i4, i5, j1, j2, j3, j4, j5, first_sum, cond_sum, total;
printf(“Enter the first(single)digit: ”);scanf(“%1d”, &d);printf(“Enter first group of five digits: ”);scanf(“%1d%1d%1d%1d%1d”, &i1, &i2, &i3, &i4, &i5);printf(“Enter cond group of five digits: ”);scanf(“%1d%1d%1d%1d%1d”, &j1, &j2, &j3, &j4, &j5);printf(“Enter the last(single)digit: ”);scanf(“%1d”, &check_digit);

本文发布于:2023-05-14 01:56:51,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/621195.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:语言   适合   答案   家乡   高能   程序设计
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图