0% found this document useful (0 votes)
53 views13 pages

Cf&om - 1

What is computer basics notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views13 pages

Cf&om - 1

What is computer basics notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

1 Computer Basics

LEARNING GOALS

After reading this chapter, you should be able to:


♦ Explain what is an algorithm.
♦ Describe the major parts of a computer required to carry out algorithms
• Explain the main characteristics of computers.
♦ Explain why programs are stored in the memory of a computer.
♦ Show how problems are solved by computers.

Computers are now affecting every sphere of human activity and bringing about many changes
in industry. government, education, medicine, scientific research. law, social scitncei;, and even
in arts such as music and painting. They are at present used, among other apphcations, to:
• Assist in bus, airlines, and railway reservation
• Send email and chat with friends using applications such as Fiicebook, Twitter, and
Skype (for video conferencing)
• Search for information using search engines such as Google, Bing. and Yahoo
• Refer to encyclopedias such as Wikipedia available on the World Wide Web
• Shop online for books, music, mobile phones, and many other consumer goods
• Simulate landing of aircrnfts
• Compose music
• Create animated movies
• Play video games, chess. and card games
• Store and retrieve data on land records
• Assist doctors in diagnosing diseases using medical images such as CAT r:,can.s
1
11111111
2 I I 1111d,111w11Ud\ ,,l C'orllf~t•r~

'c1·k (11,• ,1~ I)


. , · ,.,l
• 1\
1 app , lClllll)l
C 1 '- 1111
u,rer~' are confined
,
only by limitations
,
on, human Crear .
n ru I ('· •
111 ,11.,
.
1111.,g 111.i I 11>11 . .
1 , 111 y la'ik rh•tf
• can be carnc(_I out, systcmallcally,
. . . using a Prec1.s cc sl\1 1ty
hy•li l•'P lllt'lliod, can he pcrfrn med hy .i computer. Thc_rcJorc, it is essenti~l f~r every ect · lep,
prr.,. 1111 ioday 10 kiu>w ahour a l'.<llnp11tt•r, its :'ilrengths.' 1ts "".'eaknesses and its internal stru~ateu
I ht· riwiu ol~i'-"ctiw of 1hi, book is 10 cxph11n these 1n a s11nple language. lure.

1. 1 ALGORITHMS
In otd,·r lo solw a prnhll'lll u,i11!' a computer, it is necessary to evolve a detailed and . .
',fc"p by ~1e•p 111t·1lmtl ol M,lution. Step-by stl'p methods for solving problems are not ~~ec,se
P•~l' 1d1:11 111 co111p1111·1,, , 'f'ht·y have hccn in use for a very long time and in almost all Wal~ or
Ille. C>n,· such 11wlhmJ, lnkcn from II popular magazine, is given as Example (. (. of

Exnmplo 1.1 Recipe for Making Pot~t.'? Bon_


~a_s~ - - - - - -- -- - - -
d
lns:rcdlents
Pocatoi:!- 250 r,r·1ir11,, choj)pcd 011lon1, 3 (sm:ill), finely chopped green chlllics 5, gram flour loo
J:riHns, oll fot fry In}!, w.itor for hi1tt 1ir, or;;1lt 2 ton~poons.
Mt'thod
Srcp .1 • flpl/ fiotncocs elf/ wcikl"d, fit'd one/ masli rllcm unt/1 they ore ~oft.
SteJ, 2 Mix (,rt-<! onion~, Rtt:rn ell/Ille•!. ond 1,(1/t with t/1e mas/led potatoe.~.
Scf'p J: fokr //11/r purtiu1,s of 111,, mlxt,111• cm<I mokc \moll bolls.
St"/' 4: Mill er<1111 (111w, wm1•1, am/ " llflh• suit ond bcm well till a sniooc/J and creamy batter is
ot,rm11r.,I.
Step S· 1)11, tilt' putmo /Joi/~ 111 r/11:1 lwttcr, 7okt• out ml</ clt'('(J In oil on rr (I low f,rn.
Stf'p 6; f!lke out wht111 tho b,1lls :,rc1 frfod to a ~oldorl brown colour.
A••ult
A doxon pe>Ulto bond:is rtio\dr (0 bt1 Sl!l'Vf.lt.l --~---------1
hot with tmrnno ~s-·a~u~c_t)_,
Tlte' a·,•,pe r.1vt•11 11bl•W h11s llw folhiwing prnpnfh•s :
Ii /it,•1:111s wirh ,1 list ul 111gt\•dtt•11fs whkh ,w may rull fill' l11p111s.
i. I\ \('t/llf'l(C'(• ,f 11/\'(//l!lion,· is riven (o prUl'l'SS (ht• i11p11ts.
I, A~ H l'l'Slllt 111" 1'1111yi11r 11111 lht• i11Slt\ll'lio11s. SOllll' ,,,11,,11ts (llllll\l'ly. pot1110 hundas) .\l'l'
oh11t111cd.

'fllc:, i11slrn\'li1111-: r:ivt·n hi pn 1n.·ss llw inputs art\ lu1wl'\'l't, 110, ,,,,Tis,·. 1'lwy Ut\' nmbiguous.
J·v1 t~u111plt\ 111 Step •I. ,n- :in· t11stnarlrd tn 'b,·at wdl till n smooth und. rrl·amy ballt't i~
oh1n1m·tl' 'l11e i11t,•1p1l'l11tit 111 111' 's111t1,ifh aud t'tt·nmy' l'an v:uy fwm pt'rstin to p,:rson. Owrng
to st1t'h 1111p1t·1.·t!il' iw,t111rti1111s. tlilf1·11·11t flt'IM>11s ti.,111,,, ing till' s:uni.: l'l'ript' with tlw samt' inputs
1.-.111 phidun: 1w111111 li11mf11,; which diflc'r in silt\ sh1tpl'. 1111d tastt•'
\\ (' \\ tll 110w 1..·,.1111iu,• a11111ht•r .'-lt'p by s1q, prnt·1•dt11\, lagain tak\'ll fwm a p\l(Hil,1r
IIU~"/ JIH' ) .
Materials required
Needles No. 12:2, Wool 4 ply: 9 balls.

Method
Step 1: Case on 133 stitches.
Step 2: Repeat Steps 3 and 4, 11 times.
Step 3: Knit 2, * Purl 1, Knit 1, Repeat from * to last stitch, Knit 1.
Step 4: Knit 1, * Purl 1, Knit 1, Repeat from * to End.
····················································································
••••••••••••••u•• ••••••••••••••••• ••••••••••••••••• ••••••••••••••••• •••••••••••••••

(Similar Steps)
Result
A sweater.

The above example illustrates the following points:


I. This procedur e has inputs and a set of steps to process the inputs to produce an output.
2. The procedur e is more precise and unambiguous than the recipe for potato bondas.
There is very little chance of misinterpretation.
3. The variety of instructio ns used in the procedure is very few. If one knows how to knit,
how co purl, cast stitches on or off needles, and count, then one can knit any sweater.
4. By a proper permutat ion and combinat ion of this elementa ry set of instructio ns,
an infinite number of patterns for sweaters may be created. For example, if
Step 3 is made ·Knit L * Knit 1, Purl 2, Repeat from * to last stitch', the pattern of
the sweater will be entirely different.
The preciseness of the instructio ns combined with their small variety makes it possible to design
a machine which can knit automatic ally. In fact, a forerunner of the modem computer was a
loom designed by a French engineer, called Jacquard, in 1801, which could be 'program med'
to create a large number of patterns. The program consisted of cards with specific patterns of
holes in them which controlle d the loom.
We have illustrate d two simple step-by-s tep methods of solving problems. We will now
explain when a step-by-s tep method can be called an algorithm.
The origin of the word algorithm is not known. It is, however, generally accepted among
mathematicians that it comes from the name of a famous Arab mathema tician Abu Jafar
Mohamm ed ibn Musa al-Khow arizmi (circa 825) (literally meaning father of Jafar Mohamm ed,
son of Moses, native of al-Khow arizm), who wrote the celebrate d book Kitab al jabr
Wa/muqabla (Rules of Restorati on and Reduction). The last part of his name al-Khowarizmi
was corrupted to algorithm. An algorithm may be defined as a finite sequence of instructions
(to solve a problem) which has the following five basic characteristics:
I. An algorithm begins with instructio n(s) to accept inputs. These inputs are processed by
the subseque nt sequence of instructio ns in the algorithm.
4 r'lmtl:nncntnls of Computers

' Tht· s,•,111,,,ir,· <!( i11.1·tructio11s specified in the nlgoritlm1 must he precise and un:unbi,.
ln other won.fa. the instructions must not be vague. It must also be possible 1; ~
tht·tn m11 . Fllr ,•xnmpk, tht· instrucrion 'Go to hell ' is precise. but cannot he Cllnied -•i {i)
J . Fnch i11srm,·tii111 m11s1 be snffkkntly basic such tlmt it cnn. in principle. be C3rrie(I OQi. (i i)
hj :1 pc•rson with pnper nnd pencil. ~ (iii)
(iy )
4 . l'lw 11,1.II rim,· Ill c'tlff) ' out nil tht' stt'ps in tht: nlgmithm must he finite. As. :ilgon~
tn;I)' c,1n1nin instrn,·tions 1,, rt'petirivdy cnrry out n group of instruction,-, iliis re-q~
implies th;it thr numlwr 1,f n'p,'tithms must hr finiu.
l V)
:, . ,\n ,11µ<,rithm nmst pm1hl\' t' ,,,w m nmre <l11tpurs (n:1mdy. the re$lllt of prot' essing t..~
t'i)
111p11ts). (, ii)
n.1s,•.f ,,n r\w ''"'" ,, d,•tini!ll,n, ,, t' s,·,· thm th,• n.·.:-i1x· of lhmnpk I. I doe:- not qn:.ilit'\' -:l!-
alr,11 llhm ;I" 1t ,,, m11 pr1.,•is,·. nw 1-.nittin~ pnttrm. ,,11 the ,,thcr hnnd. dt1 l'S qu:tlif~·. • l:.
\\'r ,, tll no\\ ,,, ,,h ,, ,1 .-;1,•p-h) .-;1,•p pn.1c,•dmx· t,, s,,\v,· :\ ,!:it;\ ptxx-e,__~i11g .kh, The r.n.lll~
I!, "' 1111.I tilt' ,I\ ,'t:\tt' 11\11\\h,·1 ,,r \ ,m·,•l.-; 1\,' 1c'\l\111\g in ;\ ~hMt p;1::~;1g,'.
A -:_'nl
Ex•mplo 1.3 Proe1tdur-. to Find the Average Number of Vowels in a Passage -
- .
l N Numh<'r
----
,,t , h.,r.,cr.,,~ 0
- ,'\."ll\ll~\:
ak,,rid
~

.m,\ '-"-"
I

1C't N11ini....,, ,,t , '"'"''s - a t\w.::


R<-p<'M Sh'p, 4 , 5, (I .\1hl 7 1mtll no m,,1'\' ch,\I\\Ctc.'1'$ .w~ l~ft in the p.,ss.~t:-. ''J)('f.\
R,'-.1d 01w , h.\l .,, h'r ''"'Ill rhe1 p.,s~.\,;•'·
,\,f.f I t.') Nu111t,,,r ,,f .-h:m1n,'r1-.
tf th,• '11.,, :ld<'t i, ,\1\1 ,,11,1 -if th,1 lc.'ttt'l~ A. f, I, 0, u. :I, l.', i, o. \I, :idd l tc- Nti111~•
Of ~--\\ l"b
Mc,,<' tt' th<' 11a,1 , h-lr,,,t"l'f,
Rl"fl>.1~. St,•r ~ b. 1't'.1d1¢J ,,111) "h,,,, l\v '""''r<:l ch.w.,,t,~rs .u,~ 1t,ft ln thc.' p.,ss~~ Ii
,\tl) \ h.\l":\.;'l<'I' i:-. l<'ft I!-. i:,-'\ t,,<k t,.\ $t,'P "4.
Numh,,r \,f ,,,wds
A1<1r,\,:~ N111nh~r ,,f , "" d$ - -
Nttmh,•i- ~)f ch.w.,ctN~
Stt-t 9. Wt'ltc A,~~~ Numht-r ,,f \0\\ c.'1:-. Numbc.'r c-f ch:i1'"!\l'.h~1-s.
Sff'#' 10; Stop.
int~
nu!, Sh'I' "' ~h•p P"'\.',hll\' ,111-iltft\'!, ;\S ;Ill :11~\,dthm t\1r 11\1.' t\,l\m\ II\~ l\';\l\\)\\:-: p,~,
ti) It 11.1~ .111 input, 11.111\-•I\. !h,· p,h:-,1._~,· "' h• l'\:1mh\1.·d.
,.m
\~n
( ii) l'h, ,,\j\l,'11,\.' ,,f IIIS!t\11'(1\\(\!, 1:,: l'l\',' i!,,'I: ::1,·,-ifo•,I ,ltlll l\\'t ;\l\\bt~\h'll:<.
t iii) F.1,J1 11h11 u,1i,1n is l•.-1sh' ,111,l ,-;111 h .' ,·:m-kl\ ,,111 1,y a p,•t~l,n "hh p~l\1<'1 ,m,I \-X'n,1I
{I\) ni.• 1111.11 1\\11\ll\..... , \If lll:-l1'l,'lh\t1~ ,':1\1 i,-d ,,ut i:,: l'i111k'.
(\) l'h,• ptU,'-"htn: Tl'rll\11\,lh':- \\lh'I\ tht' t'nd ,,i th1.' l':lss.1~,' i:,: n':t1.'h,·d.
l' i) I! h.1:- ,,u1p111s. n:11\h.'I~. ""' ,t\ ,·r.1~1.· m11nl,-r \,f \,,\\,'I:,: ,md thl' munt,,'r \,f ,·l\;11;\,'I,'-'

1.2 Sli\1PLE f\iODEL OF A COi\tPUTER


If ., ltl,t,'htll,' 1:- "' be.' htilt I\) 1.'.Ul~ , 1 \ll lh,· ,ll,!!l\fl\htn ,,r F,.m1pk 1.:i, it !,I\\IU\d h.\W L~
folh1,, in~ fr.uut\',
l " 'lll'llln llthh, I ~
(I) It ~1iu11ld h,• ,1hl11 t,1 1111d II 11 1 \I V1111NIHll11 M f ll ~,11 t h, kt .
11 11
I,,,,.,"'"' '''"'" h, I, ... "'' "'11111'""" "'" I • "" •.. " "'"
I

r' II
oil) 11 h,.
uhl,·1 '"
1.. ,, ''" 111 • 1thl1
r, ,~h1111ld 11, 11tld 1111d dlvtd1,.I"' ""' """

I"I II ' hnu 1, I hn ,.r,,,.


' 'n! "I"'"' " ,,1.,.,,.,,1,,, ',..,,I h"'" ""' 1'''" •r•· '"lh !I~ 1,·u,,.
I"
A, I', •1
1111111l11 11, " 1•bi,,, I, •!, 11 IU\, I Ii II """' •h,•, ""'' """ »I i\o,•"· " "" ,,. ,.,-, .,,1,1 I '" ,I~
11, v11w,
I 111
1
1
IV) fl •1l1011ld lt1 111tl, 1,1 1,1<11,1 l,11 11 1111,• 1111\111 l 1"111\1\lllh'd I tlhH•~.
(VI) It ,il1,11tld l11 nhl,1 ill W1{11 , \Ill lllttp,,n 1111 ,1l1 ~\\1 ' l /ll llhli1h1td

"" I II I h, "'' I"


Hlh l \•1•11H1111 ,
h, II" Ii"I'"'' I"" ""In h,, ,."" h·,r "'" ""'• ..,,,,,. ,,// ,. " '"'"'" "'"" "'
,11,, I lllh, 1tl111111111111 11111•11 111• ' " ''• ,/ 1111 h' h l,'l11'1· \ • th,• .tlt•, 111111111 I\ 11h11
1
1 1
,, p1 1111 v1, l!i ,1( Ii., u 111 l 111 >41 •1~ 111 11 n n111 ·d 11111 np,1111 111111 ,t)l,1111 111111 1 ,1 "'' "' "'"II ,
~1111 11 111 d, JI 111 Ill, "i'llill1V In h11v1 1111 th, ~"'I'' ht 11111 11ll1,111ll1111 ~i. 111 ii lH ,, ~101,,fi' 1111111
1
I\ , HJiljlllfll1J •
11 111111 hl1t1l d1 i, lp11i •d 111 '1111\1 1111( 1tli1111hh1HN l,11 jll\11 ,,,\Ill)' ,I \1 ,1, 1h11,, h.l\ lh,~
,ut1p111,1111111 nl 1,1, ,11,, I I 111 1•11'1111• 1 I,
1
ti I~ ~•11•11 lh111 1111 1111•111 w11 ,, p111\i. l.' d i., 11',t.l th,•
ulinuillin1
111 u11d Ill, d11111 1,1 li11 p111, 11111111 d hy 1h1 1 lll l}111ltl1111, l'li. 111,•111, ,,y w111 11,,"'' lh,· .i lll.• '1 1\11111
1 1
, ,r, •uup111i d , 11lt1io ~. I'll, 1 1, 11 1•1111.~• 1111 /t l1111,q11,,1w1h1 1 h1•,1111,·t11111-. 1111,I 1'1111 h, 1111 ·111 ••111 h h.,~
,1t, , upul11h1 v 111 p, l !111111 111hh1111'11i 11111,111th11111, 11hmrn 1t. •1 1111ml1'11li1111,11 ,11 1, , ' " " ' " 111,I l,1111, 111
,,,11 llifhOl!t lhi ,,,,,,,,11 11,11, 1111111 11 1H dl ~phtV li 1•11111111111 ,11 11 111th;
1

I . "".,,, I • ~ll t~II 11n


I
l 1\ It l 'I I I

l f
1'l11 II 'h/-ltl\Nt I
IINII'

111111111 I, I l '11 1,1111 11111111 111 11 I llli\llllh ' I

I
l '1 I, ,,1·111 11t,11 II iN jlll'i~ l\,I, 111 ,h I I' "'" 1 111 \'l\lllllhltl • 11111111,, I 1•l ,htt, ,, ·111
'
111 I , ,111111I I 11,II\\,, 'f"llllll 11111 ,111, I l 111\II IIt'
I II 1111 II II '\\ litt ih "''' 1 11( llbltlll ''"''~ lh,~ 1111111,1 I I
i,11, II ,lltlt• f'll "111 ~ I 11 I 11• 11111 II I ,,1,111111, I ' 1•111,' ·,•ol11f1 111111 \I '" I
p11111 !pl, I , ,, ~, d 111 l111tld111p
I 1111 1,11, '"'' I '''" I 1 , ... II'j 1lII II1 ,1111111111 h 11,11111. I\
w 11 ·, Itl I I I Ii 111 111 11 ' ,,
i,
1lh111~ II h 1111,, ibh• 11, I'• 1(,11111 I 1.nr ,'

1
\'111hl 11 1111h,1111'"" •1"111 11 1" " '' 11 '

I.' ' 111\1(1\( 11 IU~ IICN ()I · ( 't '"''*'III l(fi


lllh 1,Jt,(IJ(l1 I, tlllll, ~ II f 11 l t ltlljlllh11 11111
1 It 111 lh•I 11•'\I' \ ll\ \11
1111 I l<i lll ill I ,Hh'• I\ ,11 111 ~1\lh I ,111 ~
I '1111111111< ,,, ,111 1111th lit I ,1111 ,, • . , ' II"'' II \1' 11 1•11\\i'll\1111111.11111,,
11 II It I I hl b1llh 111111~ I I
h l\11 1111111 1l1i111 ,1h11111 111
l11b11th
t
i t 1,
1111,u, ,1i. 1 ' " ' 1111 I\ . ~11111'4
I 11
I . l,11 I \111111' l ' ,II I '
a11h\11" I, ",,ii ,1 'hn\111 h I . \ I !It' "
\

I l11111fl •h I l 1111111,111 IIHHI I 11 •111, I 11111 •II ll I 111 , 111I


l.4 PROBlE.\i SOL\ 1,G t SING CO . \lPL'TERS

:.':..-.t:,
_':, 'lb :::::,~ ':t::s-, l.lf .6;., =..:.,:- ~, :::i .?.gc-::±.r;. :-c- ~,·~ u':e J:!Q~Jem is forrnu1~J. fil:'
~_f';,,ri:..:::, ~.:c;:j ~ ~~'~ :-u:::i.:-_'-t ~J ~--r.i::-ig:-~.x:.., B.s...-;ed oo our .1is..,1ssm::,,.. Tc
~-::..~ ~ .::.t"C\!;;!n .z:.__tl~~~.:l::. is .::.."E.:-..tlt ~ ti,o..1-.~~-umim: .
-
.= ~ .::.~:::=i Ii;; : : - ~ ~ j ::. ~ ~.::i...'= Ql~.:c__ ...-\n '!1~"\Ilthm e"\~,""'1 .. 51r~ !
-
;r.:-,t'-!' ::3...-c::::!~ r,; :~~ !l ,"'t...,,...~:....~ ;-r-.. gr.:a Ibe ~ x " ;:-....".U!i:lt.m is -~~e-J '!in~
!,.,.---~~-~
~:, .. - . _ ~~
.:-- "".....,..r
--.i::---..~~
(_j_ ·· tputer ~ai..101, f

We will now consicJ_cr an example ~f formulating a cornpuler algorithm l;l_,1 d writ.t ~ cou,;,t
program corrcsponc.lmg to the algorithm.

Example 1.4 Finding the Highest Marks in a Class


Find out the highest marks obtained in an eY..amination and th~ roll number of tJ" ~:.oo~r
obtaining the highest marks. For simplicity, it is assumed that only one ~w::lent 0 ~ , r'"l r; ~
highest marks.
Input
We first decide the format in which the marks would be pressmed. We a:;:;ume that ea.rJ,
student's paper will have a roll number and total marks obtained by the student.
Method
Having decided the data format, we formulate the steps needed in a procedure t0 p:ck t>,e
highest marks.
Step 1: Read the first student's paper and note down the roll number and the marks. This ;s
the highest marks found so far.
Step 2: Repeat Steps 3 and 4 until no more papers are left.
Step 3: Read the next student's paper. Compare the marks in this paper with the highest mar.cs
found so far.
Step 4: If the marks read in Step 3 is greater than the highest marks noted, then erase that
and replace it by the marks read in Step 3 and replace the roll number noted dowr,
earlier by this new roll number. Else do nothing.
Remarks: When no more papers are left we go to Step 5. Until then Steps 3 and -4 are
repeated.
Step 5: Print the roll number and the maximum marks noted.

1.4.1 Flowchart
Having obtained an algorithm for solving the problem, we express the algorithm in a pictorial
form called a flowchart. The flowchart is primarily used as an aid in formulating and
understanding algorithms. The sequencing of instructions and repetition of groups of instructions
Tu may be quickly seen by inspecting a flowchart. The flowchart for the algorithm of Example I .4
is shown in Figure 1.2.
For easy visual recognition, a standard convention is used in drawing flowchans. In this
0) standard convention, the following shapes are used for various blocks in a flowchart:
(i) Rectangles with rounded ends are used to indicate START and STOP.
(ii) Parallelograms are used to represent input and output operations.
(iii) Diamond-shaped boxes are used to indicate questions asked or conditions tested.
based on whose answers appropriate exits are taken by a procedure. The exits from
the diamond-shaped box are labelled with the answers to the questions.
(iv) Rectangles are used to indicate any processing operation such as storage and
arithmetic.
8 I F1111,l11111r11111h, ,11 l \n11p111c•, ~

I l 'iTAU'I )

""~"MAl<K.S
) _R_o_u_.NO, -)
..-~1~~-
MAXROLLNO IH)LLN<J
3
MAXMARK., ◄- MARK,,

y
4

1/
'
Ye&

5
B.E.Af)
ROLlNO. MP..?.KS
l ;..,;; ~ j ,··:

MAX ;,</ .J.,Nr),


V._;;._)'y ~ ;, it,,<;

'

Ir ~ lIE '!i:m~ n:. ~ 'I!r...!'l~ ~ : ' art;. ::Xi


~ • - ;. - ....:J:r~V~ ~: 't1K ~'Y
~mm~ axeca~ 2lE::t ~ - z -:
:g- ~ ~.,._(."'Y
- -- C'ompurc, 1111,,l·~ ))
-\ l<.',tdc, nc('d nut \\OIT) if hC' 0r sht' Lilies not full)' :I
• • l '
th~' ah:on thm. lt 1s gn en on y to sho\\ thL· render wt unc cn-tnnc1 rlw 11011111011 11,ctl 1
~ ,
1•11 •1 . <• expn:,n
progrn m look, likl'
PROGRAM ma\__marl<.s
IMPLICIT NONE
INTE GER roll no, marks. max_roH _no, 111ax_marks
READ· . roll_no, marks
max__ marks = marks
max roll_n o = roll no
DO
READ ·. roll_ no, marks
IF troll_n o == 0) EXIT! roH .no = 0 indicates no more
papers
IF (marks > max_marks)
ma~m arks == marks
max_ roll_n o = rolt_no
ENDIF
END DO
PRINT •. max_ marks , max_rolt_no
ENO PROGRAM max_marks

The above progr am is a straig htforw ard translation of


the flowchart. TL uses a precise
notat ion which shoul d be learn t by a progr amme r.

1.4.3 Wor king of a Computer


Havi ng show n how to obtai n an algor ithm and a progr
am to solve the given problem
(Exam ple 1.4), we will now illust rate how the algorithm is
executed by a computer. The model
of the comp uter show n in Figur e 1.1 will be used for illustr
ation.
We will assum e that the flowc hart of Figur e 1.2 is first
read by the input unit and then
stored in the comp uter's memo ry. (Strictly speaking, a progr
am, and not a flowchart, is read
and stored in a comp uter's mem ory . We use the flowchart,
instead of the program, only because
the reade r may not know a progr ammi ng language.) The
data to be processed, namely. a set
of paper s, each with a roll numb er and marks, are queue
d up at the input unit in the order in
which they woul d be used by the flowc hart (see Figur e
1.3).
The proce ssing unit of the comp uter reads from the memo
ry the first block in the flowchart
which says 'STA RT'. This instru ction gets all the units
in the computer ready. After this.
the proce ssing unit retrie ves from the memo ry the next
instruction given in the flowchart
(bloc k 2 in Figur e 1.2) whic h states:

READ ROLLNO, MARKS


This comm and is interp reted as 'Read the first numb er from
the data record "'.'ailing at the_ to~
of the queu e at the input unit. Labe l a box in memory
as ROLLNO. Clear _It and store 111 it
the numb er read. Simil arly, store tl1e secon d numb er from
the data record m a memory box
labell ed MAR KS'. Figur e l.3(b ) illust rates this.
M,·111111, l\q~,,
1{1)1 IN•\
If IS in\(;
\

l I th~ 111pu1
ROl I,;-.:()
cont~nh 1

\~ ,:x1
'\

L -l
fi~•

~J
'" :i,!-c-,tl
1h~n th.:-1
:--t,)rCd i
\h.:- pat
~)f t-,,.,,
M \ '\.R
~\

~'I},,,\,\ ,\.. '"'""'''" . ,, ~ ... ~ '\N~ , ,\,~ v~.'>,1 ,~, l'',,~l ,, {'\.<,, U'l',~ th,, "•'-l ,~~
), ,._,,_'\'I.

'\,'\.-._ .. • ..'
,"'\.:.,, -ci'-.~ . -. ,\..."'- ',
, '\. -l:'-
... :, '-I': ') ' ' ~\\\ '"'! ,.
'~ -~'
'•~.,,..,. •' ,..,
" "',,H'-t,
'\,\ · ',..._, ,. U I~ \
'.,. ........._.,. ~•
l"\,o11.tJ~,,,.._

;:t-~~" '" \. \ \. , , ' .. '\, \ , ",':'' ..¾,' ~


·1, . h.i,, ,','- ',,'"N ...,,f •"~tt'\."l~
" i,.,, ~"\ "" l. ~--- , \ \'\\'. \~-~~ ,\\'~ ."ll,' , ,.._;:- ,-.._"nt~!J:,,

;{...'\~ .... ..,~... ~ ,-:.: ~'-. s


~~, x,~" _,-~
'f, ,'\,; I. ......... ~
' ~~~ -. ~ .:: ~ ~ ~t..., ' ~
lt is interpreted as before and th~ numbers in the paper waiting at '.ht' h'l' of lht' '-\U('lk ,,
. put unit, namely. paper 2 (Figure 1.3). are read and the \'alu~, 10 1t ,m.' ,t\,n.-J m ll,.,\~· ,
th e Lil ' C\.C\.'Ullllf :i,i._ ,·i-.r·,i--twn ,""-·
· en.r1·1er contents. \fter
· th e1r
oLLNO and MARKS arft er _eras111g
R nts of memory boxes will be as shown in Figure l.5.
conte , ~

MAXROLLNO ROl l ,O
MAXMARKS

0 450

Figure 1.5 Status of memory bo,es after executing in~tru\·thm~ in b (X" -4 ,md
block 5 of Figure 1.2.
1
Next. block 6 in the flowchart is reached in" hich a quc-,ti0n 'b \I \RkS , \ t \ '\. \ 1 \~1'.S
is asked. This is interpreted ns 'ls the number st0rl.)d in nwmot) t,..), \,1~·!k'\1 \1 \R1'.S ~l\'.\t,•r
tlrnn the number stored in 1\1AXl\1:\RKS'?' Refomng to Figure l.5, "-' ,,.,' th;11 1t\t• •wmt--.•1
stored in MARKS, namely, 78, is greater thnn that stored 111 l\ l.'-\ '\\ l -\RkS, n;uud), :-.:. 1 "'''"·
the path labelled ·Yes· is followed and bl\)Ck 7 is n-ncht·d. which tnst1111:ts th.11 th,· "''tll,•:u,
of box MAXMARKS should be replaced by the Clmlt'nl1' ,)f l\ L\lU;.s an,l th,' '-'\)~*·ut:-. \"'!
MAXROLLNO by the contents 0f ROLLNO. The status of vnlne~ :-.h't\',l 111 mt'llk'l) tx,,l., ,1t
the encl of this step is shown in Figure 1.6.

MAXMARKS l\lAXROLLNO ROU.NO \1 \1'kS

78 521

t Copy

Figure 1.6 Status oi memory bn,f's ,,ftN t"'\t't 11t1n~ in:-trn1.-111,n:- in bl\'l "-' (, ,,nd ., l)I
figure 1.2.

The path lending out or hll1ck 7 in tht' tl1)\h'hnrt k:1\\s h\\l'K h~ M, 1,·k -l ,,r th,• ,'\I.II t
Executing hlnck 4, we :-:eo that n papt'r is still lt'ft, l-ht','\ltin~ \11\\'k \ th,' m1ml,•1, ~('-I ,,11,t
54 are rend into ROIL.NO nncl l\ tr\R KS, 1<':-p,x•tivc-lv lF\}~lllt' I.?). F'u·,·111111~ M\,'t,, o, ,, ,, s,·,·
lhat 54 ~toretl in MARKS is lt-ss thnn 7~ st111\'\l ln l\lX\~1.\Rk~. \'ln1,, ti\\' ''x,1 ' 11.;1th 1:-. t,1k,•11
oul of hluek 6 and Wt' rt•ad, hlo\'k -L
Jot
MAXMARKS MA\.ROI LNO

, --1 r 5~1
l l
, Wht•u hlnck •I is ~xt•1·11t.·d, wt' s,•1• th111 1w 11\\II\' p,\\'n, Id\ 11, th\' \lll'\\l q\1,'IW.
lit\'
11111 ~, l'Xt•rntion 11f hlol'k ., gtws 'NO' l\S ,11\SW\'I 1111,I \\1' ,~1,d1 h\,"'l.. ~ ,,r th,, n\,\\\-h,\£1
I
J2 Fundarnentab of Compurcrs -----

~
The imtruct ,on ·111 bJ
1
·k 8 comm:m d \ that the contents b · 521MAXROLLNo
h of boxes
b oi.; ' I •d by Ih C Olitput unit. TilUs. t e num ers
and
an. d 78 are Print,.,,
'1J
MAXMARKS arc
After dorng this, to
the e.
mstru

pnn c
ction .
rn bJ oc k 9 is reached which stops computation. ·

1.4.4 Stored Program Concept .


. dm
f mputer use · ·'iis
u section was first proposed m. 1945
. by John Yon Neu"'
•11ann
The mode/ 1 o o
c_
• •• engineer tume d computer scientist. The major
. contnbut1on of Von Neumann
. is the·
a.dchem,ca . a program aod the data to be .processed
r stonng . rn the same · Stonng a Program
· · Imemory.
, "o . 1s
memory . tial ;r a series of ;nstructmns " to be <epe""ve
. . essen .h y earned out. Fo, ;nsta nee
. the a 1gont m returns
~n Examp1e 1•4 , after Steps 3 and .4 are carried out.
m b . the previous Step,
to
. more pape rs• are left in lhe rnput.. The previous step cannot e earned out Unle•s
3 ,1 ,. n. ,,.
·stored' and is available for reference in the memory . . .
S
. a program in memory also makes the. operation
] . tonng . .of computers
. . . DnJ'k
automahc. t
ulator where one has to press buttons after each operation 1s earned out, the l11StnJc,:
e,
ca c b . "on
stored in the memory of a computer are taken one y one autornat1ca1ly to the processing u .
.
interpreted, . .
and executed without human mtervent1on. n~1

1.4.5 Hardware and Software

TI,e model of a compute, we described in Sect;on 1.2 (figure I.I) is h;ghly s;mpJ;fied. It .
used to expJa;n how algorithms are executed by computecs. A ceaJ computer ;s moce eom ~•
It has several Input un;ts. For example, a desktop computer wHJ have a keyboa,d. , mo ve,
scannec, a mkrophone. and a video camera as input un;ts. A compute, also has severa1 m,":·'
units. Apart from the main memory shown in Figure l.J, a compute, has disk storage, CORO~
and removable pen drive. The processing un;t consists of a microprocessor and a numi,,, •
support chips. The computer also has many output units. The most common output unio .,
a video monitor, a printer, and a speaker.

The block diagram of a compute, shown in Fig, l.J ;s that of a 'stand-:done' eomp"'•
Nowadays an isolated single compute, ;s rare. A computer has a Network lnte,fa" corn
(NIC) which connects it to other computers. A computer also has a unit called , 'Oodem ,mo
connects it to the Internet-a worldwide network of computers. A computer not connected to
the Internet cannot use applications such as email, Facebook, Twitter. etc.
The units of a computer we described above constitute what is known as hardwar1·. A
computer is useless unless it has a nurnber of ready-made progrnms to enable easy use of ii._.
hardware. This is provided by software. The 1110,1 ;mportunt software rcquh,d to u,e a'""'"
is what is known as an Operating System (OS). An OS coordinates U1t! uctivitics of ,-ruii;;;
parts of a computer. namely. the CPU. the Input- Output units. and the memoi). It optinu..":<
the use of !he resources of a computer. Bcs;des the OS, it is ttlso ""nti:tl !Or''"'"~'"' LS
have a set of application progGuns. The most ;mporl:tn! applkuHou pt\1grans '""';" ot' '. ' l.6
processor, a program to scnd/recdve email, ont: which systcmntkally Ol'/!UHi11.·s .1uJ .tN'•~ , l.7
. . dala, anti a program lo al'cess thl' World \V1t. {e \Vell,
retnevmg i.. I
n t IIt' 1· llowing, rhap1,·1). .
0 l.8
will describe some of thesl' application programs.
i •llllf\\ll.'T 1\,hl, ~ ) 3

\\,' :-..\\\\\\\\,\\• ,, \hi\\ \h,' \\\,\\\\ p, 111,,, p,,,,,,\\k,I I\\ 1hb ,'h,l\'I, I

,. h, ,\\\k\ ,,, ,,,:\, .\ \'\\'''"'"' "~"'~~ ., '''"'''''"'', \I h 11. •'·''"''f' 11, ~, ,,h ~ .m nlwITTthm
: ' "''~',\\\t~\\\ ,, .\ 11\nh~ ,,\\\'-'''-',' ,,r 1\\,\1\l,'ll,,1" F.vh ln,1t1i.•11,,n ,, pi-', 1,:"1, Ho,nnh1! 11C)11,,
,\\\\\ ,'.\\\~\\t,' ,,t t,,,,11, , \\,h1,\ , 111t t,, ,1 11\.1,•hm,1 111 n h1111, 1 11111,, t\lt\.'\l oh,\Jtthm, X\tll
t\\,, \'~'\\\, ,\\1,\ , 1\\q'III'
,\.. , "''~'\\\,'' ,, ,, \\\{1,hm,, ,, t111'h ,,\,\'\It,•, ,,n t1\~1tw11l11\I \\ 1ill,'n t,, """'"''' ,brn l<',t r<,
, ,"h\ \lh\.\\\, ,,, 1'1,, 1\'1\\ .i ,,1,\1\\, 1 ,,,

"- , ,, ,,~\,\\\\h\'\\ ,, ,,, 1,1, "•',\ 1\1 1\ ~•h1ph11-.1\ "'"" l-.11,," n U'\ n 11<)\\,h,m , 11,,,,. h.m "
\\: \ ,t, ,,,,L,, \\\ ,.1,I \\ll,kl,\\1\1,\h~\ ,,, \llf,'1\lhll\\,
~ \ \ ,~\,m\\\\\\~~ \,\\~l_\\,\f,' '" ,, ,,,,.,,1,,' n,,t,\h,\\\ H,,•,1 t,\ ,'\l'h',, .,1~',\fitl11n, J\n .1lr,wuhn,
,,., ,,,,,,\ 1\\ ,, \\\1~\h\\\\\m\~\ h1\\~1ms,1 , , ,\1ll,-.t n ,·,,111p11h'1 l''''Jlh'"'
"' \ ,,"\~~\t,'\ i, ,t,,~}\\,',\ \\''"il t~''" h'\,h' ,'l\.1bl, 1 ,t "' 1w,'-\',, ,l!lt.1 It h;1, ,,n
1111ib "'
- -.: \\ \\,,-~ ,'-'•'-'\'\\ th,' ,\m., m1,\ \h, \ ' " ' } ~ " ' ' " h' l'"'' •'" ,11,,
1
lt ,t,\t-', tlh·,.- ,b,.,
.\ ,\ \~,., p1,,t1t1\\1 \\'\\ 11•, ,' ,\ tt\''" lhi' n1,'m,11, 11n11 ,, ml,'fl'h'li",I ~n,1
""'"'\' .,,\ h\ ,i J' , , , " ~ ttm), \'h,' , ,1,,1\1, ,,(' ,. ._ ,111,,1,1:1t11 ,11 ,11 ,• ,t.w,·,t rn m,'m,\\, .in,t
, "'\ \h\\\~ ,\\\ I

· ,\ ''\' ,\\ ",,,,,•n11:1l "' 1,,,m,,l:11.· ,.,,,1,'i,,\ ,._.l','"'"" nlt,\ntlm,,


,.;\\l\\\\ '\, 'I'Ill 1, 'II,

~ \,\ ,'~ , , .\, ''"'l'llh'I ;II\' 1t, ,,,•,\\, ·'-"'"""'', ,,·1,,111\11, ,., ,,.,1,"'""
,\l ~~, ,\\\.' \''\')::.1,11n ,'\,\ n1i,,n \\ 11\\,,,11 \111"'·'" 11\t.'\\ ,·1111,m, :\n,I ,'Jl); ,,,,~
., \ ,'\_\,\\'~''\•,II\,' ,,h, h'lll\lh'l\ ,\1\\ 1\n\\\l1,'\ ,,t 11\ll,',
•. "•'" ,·•~' "·' '"':1:~'1:1,'\' ,, ~,,,t\t,'d \ \''"''""''~ ,\\\' ,,,,,111~,-,.,.,, ,_, ,11\1.:-1 ,~,\l\\pnl,'1' \\'-H'S;
~ ~"i\\,._., m ..>-t1~,'\" ,'~1,\ .111,l 11, Ill,' \1\h'\'\\,'1 111-11~ ,\ 11\\h\.'m.

-- - - - -

' '
'
' '
--- L - -

l.t i\..~ ,~:t -~ l',","-l'" l\\\l\\ :\ \'-'!'\\\.\\' m:~.,,11,,' ~,1.1 ,'\\'l\'" u m :, ,i--1' 1,, , ..,, l\t,,,..,t1, .,,
~\ ,'\ \'f\'-',',~\\\"' ~\\,'I\ l\\1 .\ \\'\'I\'' 11\ ,\ ,,~,I. I\\',\.\.. U\~ 1h'I I," ~,•~,'\} fil)

l..S \\~
" ..1 ~-'~r-...1mt,\\~ kt\\~"-~'-'''
.. \\ \ .., " .:l. ,'\~,~~•"l f't\\~f,\\\\'\
l.' ~
• ~'.\I, ... ~ .,i.. ,t,~~1~m ,,, {\ ,'l\t\'ll\\t,'f \•\.phnn th,' nm,'\\,\\\ ,,t ,~'l\ ,,, th-' N,,\..,
~~ it'!..~-~ • ~ .. ~ r,t\"-"'i.,tnw t,, hn,t th,, h\,,~h.-,, n\.\tl-., ,~\\,m'I-.,\ ,,, ,, "'""' '"''\ t\ \t I\,
:-;.: ~ :\'I\\~ l'l\l,~, -~t.l\\'tt";.l
l.<11 ~~ ~ ~ \'4\,~u"" ,,1 \',.m\f,l." \ 4 "''"'''th-',\\,'\,'}"' \\1A1\-, ,\t "- ,·'~"

You might also like