
ALGORITHMANDDATASTRUCTURE1
Lecturer:MUGHEGODLOVE
Exercise1
WriteanalgorithmthatdisplaysthemessageHello.
Exercise2
Writeanalgorithmthatallowstheusertoentertwonumbersanddisplaystheirproduct.
Exercise3
WriteanalgorithmthatexchangesthevaluesoftwointegersAandBenteredbytheuser,then
displaysthemaftertheswap.
Exercise4
Writeanalgorithmthatdetermineswhetheranintegerenteredbytheuserisevenorodd.
Exercise5
Writeanalgorithmthatdisplaysthelargestofthreeintegersenteredbytheuser.
Exercise6
Writeanalgorithmthatevaluatesagradeenteredbytheuser.Ifthegradeisgreaterthan10,display
Passed,otherwisedisplayFailed.(Note:thegradeisbetween0and20.)
Exercise7
Writeanalgorithmthataskstheusertoentertwonumbersmandnandthentellswhetherthe
productofthetwonumbersispositive,negative,orzero.
Exercise8
Writeanalgorithmthatcalculatestheabsolutevalueofanintegerenteredbytheuser.
Exercise9
Writeanalgorithmthatcalculatestheaverageofthreeintegersenteredbytheuser.
Exercise10
Ashopgivesa15%discountforpurchasesover200units.Writeanalgorithmthatreadsthetotal
price(beforetax),appliesthediscountifapplicable,andadds20%VAT,thendisplaysthefinal
total.
Exercise11
Aphotocopycentercharges:0.25percopyforthefirst10copies,0.20percopyforthenext20
copies,and0.10percopyforanycopybeyondthat.Writeanalgorithmthatreadsthenumberof
copiesmadeanddisplaysthetotalcost.
Exercise12