C语言程序设计现代方法第二版习题答案Word文档格式.docx

上传人:b****5 文档编号:15940721 上传时间:2022-11-17 格式:DOCX 页数:85 大小:42.64KB
下载 相关 举报
C语言程序设计现代方法第二版习题答案Word文档格式.docx_第1页
第1页 / 共85页
C语言程序设计现代方法第二版习题答案Word文档格式.docx_第2页
第2页 / 共85页
C语言程序设计现代方法第二版习题答案Word文档格式.docx_第3页
第3页 / 共85页
C语言程序设计现代方法第二版习题答案Word文档格式.docx_第4页
第4页 / 共85页
C语言程序设计现代方法第二版习题答案Word文档格式.docx_第5页
第5页 / 共85页
点击查看更多>>
下载资源
资源描述

C语言程序设计现代方法第二版习题答案Word文档格式.docx

《C语言程序设计现代方法第二版习题答案Word文档格式.docx》由会员分享,可在线阅读,更多相关《C语言程序设计现代方法第二版习题答案Word文档格式.docx(85页珍藏版)》请在冰豆网上搜索。

C语言程序设计现代方法第二版习题答案Word文档格式.docx

Dimensions:

%dx%dx%d\n"

length,width,height);

printf("

Volume(cubicinches):

%d\n"

volume);

Dimensionalweight(pounds):

(volume+165)/166);

return0;

}

4.[was#6]Here'

sonepossibleprogram:

inti,j,k;

floatx,y,z;

Valueofi:

i);

Valueofj:

j);

Valueofk:

k);

Valueofx:

%g\n"

x);

Valueofy:

y);

Valueofz:

z);

WhencompiledusingGCCandthenexecuted,thisprogramproducedthe

followingoutput:

5618848

0

6844404

3.98979e-34

9.59105e-39

Thevaluesprinteddependonmanyfactors,sothechaneethatyou'

llgetexactlythesenumbersissmall.

5.[was#10](a)isnotlegalbecause100_bottlesbeginswithadigit.

8.[was#12]Thereare14tokens:

a,=,(,3,*,q,-,p,*,p,),/,3,

and;

.

AnswerstoSelectedProgrammingProjects

4.[was#8;

modified]

floatoriginal_amount,amount_with_tax;

Enteranamount:

"

);

scanf("

%f"

&

original_amount);

amount_with_tax=original_amount*1.05f;

Withtaxadded:

$%.2f\n"

amount_with_tax);

Theamount_with_taxvariableisunnecessary.Ifweremoveit,theprogram

isslightlyshorter:

#include<

floatoriginal_amount;

seanf("

original_amount*1.05f);

Chapter3

2.[was#2]

(a)printf(%8.1e"

(b)printf("

%10.6e"

(e)printf("

%-8.3f"

(d)printf("

%6.0f"

5.

respectively.

[was#8]Thevaluesofx,i,andywillbe12.3,45,and.6,

1.[was#4;

intmonth,day,year;

Enteradate(mm/dd/yyyy):

%d/%d/%d"

month,&

day,&

year);

Youenteredthedate%d%.2d%.2d\n"

year,month,day);

3.[was#6;

intmain(void)

intprefix,group,publisher,item,check_digit;

EnterISBN:

%d-%d-%d-%d-%d"

prefix,&

group,&

publisher,&

tem,&

check_digit);

GS1prefix:

prefix);

Groupidentifier:

group);

Publishercode:

publisher);

Itemnumber:

item);

Checkdigit:

check_digit);

/*Thefiveprintfcallscanbecombinedasfollows:

%d\nGroupidentifier:

%d\nPublisher

code:

%d\nItemnumber:

%d\nCheckdigit:

prefix,group,publisher,item,check_digit);

*/

Chapter4

2.[was#2]NotinC89.Supposethatiis9andjis7.Thevalueof(-i)/jcouldbeeither—1or—2,dependingontheimplementation.Ontheotherhand,thevalueof-(i/j)isalways—1,regardlessoftheimplementation.

InC99,ontheotherhand,thevalueof(-i)/jmustbeequaltothevalueof-(i/j).

9.[was#6]

(a)638

(b)321

(c)2-13

(d)000

13.[was#8]Theexpression++iisequivalentto(i+=1).Thevalueofbothexpressionsisiaftertheincrementhasbeenperformed.

2.[was#4]

intn;

Enterathree-digitnumber:

%d"

n);

Thereversalis:

%d%d%d\n"

n%10,(n/10)%10,n/100);

Chapter5

2.[was#2]

(a)1

(b)1

(c)1

(d)1

4.[was#4](i>

j)-(i<

j)

6.[was#12]Yes,thestatementislegal.Whennisequalto5,itdoesnothing,since5isnotequalto-9.

10.[was#16]Theoutputis

onetwo

sincetherearenobreakstatementsafterthecases.

AnswerstoSelectedProgrammingProjects2.[was#6]

inthours,minutes;

Entera24-hourtime:

scanf("

%d:

hours,&

minutes);

Equivalent12-hourtime:

if(hours==0)

12:

%.2dAM\n"

minutes);

elseif(hours<

12)

hours,minutes);

elseif(hours==12)

%.2dPM\n"

else

hours-12,minutes);

4.[was#8;

intspeed;

Enterawindspeedinknots:

scanf("

spee

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1