ChapLer l 2 Nome two lopot Jevlces keyboard mouse 4 wby ls secooJoty stotoqe oeeJeJ? Secondary sLorage ln Lhe forms of Cu's uvu's flash drlves floppy dlsks eLc are needed because once Lhe compuLer shuLs down all Lhe daLa sLored ln Lhe maln memory wlll be losL 6 wbot ote tbe two types of ptoqtoms? 1he Lwo Lypes of programs are sysLem programs and appllcaLlon programs SysLem programs conLrol Lhe enLlre compuLer llke an operaLlng sysLem of one's personal compuLer AppllcaLlon program on Lhe oLher hand conLrols lndlvldual and lndependenL appllcaLlons such as word processors games eLc 8 wbot ls o sootce ptoqtom? Source program ls a program wrlLLen ln a hlghlevel language WlLh hlgh level language we mean Lhose Lypes LhaL are easy Lo remember and undersLand by Lhe programmers Lo avold errors ln one's Lasks 10 wbot kloJ of ettots ote tepotteJ by o compllet? 1he compller's [ob ls Lo LranslaLe Lhe hlghlevel language lnLo machlne language for Lhe compuLer Lo undersLand Powever when Lhe programmer lnpuLLed a wrong code Lhe compller ls Lhe one Lhe deLecLs lL Compller checks Lhe source program for synLax error Powever lL ls noL Lhe [ob of Lhe compller Lo correcL lL buL sLlll Lhe programmer Cnce Lhe codes are correcL Lhe compller can now successfully LranslaLe Lhe hlghlevel language lnLo machlne language 12 wby woolJ yoo ptefet to wtlte o ptoqtom lo o blqblevel looqooqe totbet tboo o mocbloe looqooqe? As dlscussed machlne language ls ln blnary code conslsLlng of only 0's and 1's WlLh Lhls Lhere ls a huge probablllLy LhaL programmers wlll end up havlng errors ln Lerms of how many 0's or 1's does a speclflc code have WlLh LhaL hlghlevel language ls lnvenLed so LhaL programmers wlll undersLand lL preclsely glven LhaL Lhey are ln a readable and a more comprehenslve form LhaL even lf nonprogrammers vlew lL Lhey can aL leasL geL a good lnslghL of whaL's Lhe source code ls abouL
14 wbot ote tbe oJvootoqes of ptoblem ooolysls ooJ olqotltbm Jeslqo ovet Jltectly wtltloq o ptoqtom lo o blqblevel looqooqe? Llke any oLher problem programmlng requlres greaL plannlng noL LhaL lL ls recommended Lechnlcally buL lL also helps you Lo do Lhe [ob efflclenLly and ln Llme uo noL geL me wrong problem analysls and algorlLhm Lake Llme Loo Powever dlrecL codlng ln a hlghlevel language wlLhouL prlor analysls on whaL problem one ls golng Lo solve may lead Lo more errors LhaL he/she mlghL encounLer ln Lhe mlddle of Lhe work 1here mlghL be compllers Lo deLecL your errors ln Lhe process buL Lhe debugglng lLself and LesLlng requlres more Llme So Lo avold Lhese lncldenLs and compllcaLlons problem analysls and algorlLhms are suggesLed 16 ueslgn an algorlLhm Lo converL Lhe change glven ln quarLers dlmes nlckels and pennles lnLo pennles 1. Cci amouniQuaricr 2. Cci amouniDimcs 3. Cci amouniNiclcls 4. Cci amouniPcnnics 5. Convcri amouniQuaricr inio amouniPcnnics amouniPcnnics amouniQuaricr 25 6. Convcri amouniDimcs inio amouniPcnnics amouniPcnnics amouniDimcs 10 7. Convcri amouniNiclcls inio amouniPcnnics amouniPcnnics amouniNiclcls 5 8. Convcri amouniPcnnics inio amouniPcnnics amouniPcnnics amouniPcnnics
18 ueslgn an algorlLhm for Lhe average mlles per gallon from Monday Lo lrlday 1. Cci amouni of gasolinc cvcry day. (amouniMonday, amouniTucsday, cic.} 2. Cci iIc avcragc icniaiivcAvcragc amouniMonday + amouniTucsday + amouniWcdncsday + amouniTIursday + amouniFriday avcragc icniaiivcAvcragc / 5
20 ueslgn an algorlLhm for heron's formula 1. Cci a. 2. Cci l. 3. Cci c. 4. Find s. s (1/2}(a + l + c} 5. Cci iIc arca. icniaiivcA s - a icniaiivcD s - l icniaiivcC s - c icniaiivcAnswcr s icniaiivcA icniaiivcD icniaiivcC arca sqri icniaiivcAnswcr
22 ueslgn an algorlLhm for Lhe A1M glven condlLlons 1. Cci amouniWiiIdrawal 2. CIccl amouniDalancc 3. CIccl if ossillc If amouniWiiIdrawal > $500 Prini 'Maimum amouni of wiiIdrawal is only $500' Co lacl io 1.
If amouniWiiIdrawal > $300 amouniEccss amouniWiiIdrawal - 300 Prini 'TIcrc will lc a cIargc of 4% for iIc amouni ovcr $300. Prcss 'ycs' if you wani io coniinuc, and 'no' if don'i.' If 'ycs' amouniWiiIdrawal amouniWiiIdrawal - amouniEccss Elsc Co lacl io 1.
If amouniWiiIdrawal > amouniDalancc Prini 'You do noi Iavc sufficicni lalancc. If you wani io wiiIdraw iIc rcmaining lalancc, rcss 'ycs', if noi, rcss 'no'' If 'ycs' amouniWiiIdrawal amouniWiiIdrawal - $25.00 Elsc Co lacl io 1.
If amouniDalancc 0 Prini 'You Iavc 0 lalancc. You arc noi allowcd io wiiIdraw anyiIing.'