最新C语言全部题目及答案文档格式.docx

上传人:b****6 文档编号:16141733 上传时间:2022-11-20 格式:DOCX 页数:23 大小:23.18KB
下载 相关 举报
最新C语言全部题目及答案文档格式.docx_第1页
第1页 / 共23页
最新C语言全部题目及答案文档格式.docx_第2页
第2页 / 共23页
最新C语言全部题目及答案文档格式.docx_第3页
第3页 / 共23页
最新C语言全部题目及答案文档格式.docx_第4页
第4页 / 共23页
最新C语言全部题目及答案文档格式.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

最新C语言全部题目及答案文档格式.docx

《最新C语言全部题目及答案文档格式.docx》由会员分享,可在线阅读,更多相关《最新C语言全部题目及答案文档格式.docx(23页珍藏版)》请在冰豆网上搜索。

最新C语言全部题目及答案文档格式.docx

3.(a)Writeaprogramthatcalculatesanddisplaysthenumberofminutesin15days.

(b)Writeaprogramthatcalculatesanddisplayshowmanyhours180minutesequalto.

(c)(Optional)Howabout174minutes?

ANSWERS:

#include<

stdio.h>

intmain()

{

printf("

Thisismyfirstprogram!

"

);

return0;

}

Thisismysecondprogram!

1"

2"

3"

4"

1234"

%d%d%d%d"

1,2,3,4);

floatdays,minutes;

days=15;

minutes=days*24*60;

Thenumberofminutesin15daysare%f\n"

minutes);

floatminutes,hours;

minutes=180;

hours=minutes/60;

180minutesequalto%fhours\n"

hours);

minutes=174;

174minutesequalto%fhours\n"

Exercise2:

DataTypesandArithmeticOperations

1.Youpurchasealaptopcomputerfor$889.Thesalestaxrateis6percent.WriteandexecuteaCprogramthatcalculatesanddisplaysthetotalpurchaseprice(netprice+salestax).

2.Writeaprogramthatreadsintheradiusofacircleandprintsthecircle’sdiameter,circumferenceandarea.Usethevalue3.14159for“π”.

3.Writeaprogramthatreadsintwonumbers:

anaccountbalanceandanannualinterestrateexpressedasapercentage.Yourprogramshouldthendisplaythenewbalanceafterayear.Therearenodepositsorwithdraws–justtheinterestpayment.Yourprogramshouldbeabletoreproducethefollowingsamplerun:

Interestcalculationprogram.

Startingbalance?

6000

Annualinterestratepercentage?

4.25

Balanceafteroneyear:

6255

 

ANSWER:

floatnet_price,sales_tax,total;

net_price=889;

sales_tax=net_price*0.06;

total=net_price+sales_tax;

Thetotalpurchasepriceis%g"

total);

Pleaseinputanumberasradius:

\n"

floatradius,diameter,circumference,area;

scanf("

%f"

&

radius);

Thediameteris%g\n"

diameter=radius*2);

Thecircumferenceis%g\n"

circumference=radius*2*3.14159);

Theareais%g\n"

area=radius*radius*3.14159);

floatSB,percentage,NB;

Interestcalculationprogram\n\nPleaseentertheStartingBalance:

SB);

PleaseentertheAnnualinterestratepercentage:

percentage);

NB=SB*percentage/100+SB;

\nTheBalanceafteroneyearis:

%g"

NB);

Exercise3:

Selectionstructure

1.WriteaCprogramthatacceptsastudent’snumericalgrade,convertsthenumericalgradetoPassed(gradeisbetween60-100),Failed(gradeisbetween0-59),orError(gradeislessthan0orgreaterthan100).

2.Writeaprogramthataskstheusertoenteranintegernumber,thentellstheuserwhetheritisanoddorevennumber.

3.Writeaprogramthatreadsinthreeintegersandthendeterminesandprintsthelargestinthegroup.

intgrade;

printf("

Pleaseenterthegrade:

scanf("

%d"

grade);

if(grade>

=60&

&

grade<

=100)

Passed."

elseif(grade>

=0&

60)

Failed."

else

Error."

return0;

inta,b,c;

Pleaseenter3integernumbers\n"

ThenI'

lltellyouwhichisthelargest\n"

%d%d%d"

a,&

b,&

c);

if(a>

b&

a>

c)

%disthelargest"

a);

elseif(b>

a&

b>

b);

elseif(c>

c>

b)

c);

They'

reequal"

inta;

Pleaseenteranintegernumber\n"

lltellyouwhetherit'

sanoddorevennumber"

a);

if(a%2==0)

%disanevennumber"

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

当前位置:首页 > 幼儿教育 > 育儿知识

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

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