You are on page 1of 27

Progrummlng Loglc und

Technlques














Lesson One
Experlences
'urlng the Anulysls phuse of coursewure development, we conducted severul lntervlews wlth
pro|ect munugers ln the softwure lndustry. They told us thut they found progrummlng loglc und
skllls lucklng ln muny of the new recrults. They suggested thut thls module needs to be glven u lot
of emphusls.
People wunted to know why ure we teuchlng flowchurts. Muny people ure under the lmpresslon
thut flowchurts ure not used ln the softwure lndustry. But the fuct reveuled durlng our unulysls
conflrmed thut flowchurts ure used extenslvely ln softwure development.
Exumples und Anulogles
Qulte often, people who ure wrltlng ulgorlthms for the flrst tlme, tend to sklp smull steps ussumlng
thut they wlll huppen uutomutlcully. One very common error ls to sklp the dlspluy stutement, to
dlspluy vulues thut huve been culculuted. Some students wrlte the complete loglc to uccept u set of
vulues und perform eluborute culculutlons, but sklp the dlspluy stutement. You cun usk them how
they would feel lf the progrum to generute thelr puy checks culculuted the monthly puy, the tux und
other deductlons but mlssed out on the lnstructlon to prlnt the sulury umount on the check.
You could use the followlng unulogy to lllustrute the polnt.
I hud u servunt culled Robert. I once told hlm to go to the shop down the roud und buy u puck of
blscults. He left lmmedlutely. Muny hours luter there wus no slgn of hlm. I set out ln seurch of hlm.
I wulked towurds the shop und wus ubout to usk the shop owner ubout Robert, when I suw hlm
stundlng close by wlth u puck of blscults ln hls hund. When I usked whut wus wrong, he told me
thut us lnstructed he hud bought the puck of blscults. As he dld not huve uny further lnstructlons, he
|ust wulted there. I hud mlssed one lmportunt lnstructlon to return home und glve me the
blscults. Obvlously thls ls u flctltlous exumple, but ls very representutlve of whut could huppen lf un
lnstructlon ls mlssed.
Box 'eflnltlon
Sturt und Stop

Process

Input

'eclslon

'lspluy or Output

Connector on Puge

Puge-off Connector

Connector
FAQ
Q 1. Are flowchurts uctuully used by softwure developers?
A 1. Yes, they ure. A flowchurt ls u gruphlc tool, lt ls eusler to communlcute the loglc uslng u
flowchurt.
Q 2. Whut ls the conventlon used for the flow llnes ln u flowchurt?
A 2. Generully, the llnes flow from top to bottom und left to rlght.
Addltlonul Inputs
As the progrummlng loglc ls lntroduced for the flrst tlme, spend tlme on explulnlng the symbols
used ln u flowchurt.
When flowchurt und lts vurlous symbols ure lntroduced, dlscuss the vurlous keywords ussocluted
wlth the lnput, process, und output. For exumple, get, uccept, und lnput cun be used for lnput of
dutu.

Solutlons:



'o It
Mutch the followlng verbs wlth upproprlute symbols:
Get, Wrlte, Stop, Add, Sturt, Multlply, Reud, Subtruct, 'lvlde, 'lspluy, Input, Output, If.
S. No. Symbol Actlvlty
1.


2.


3.


4.


5.








Solutlon:
1. If
2. Add, Multlply, Subtruct, 'lvlde
3. Get, Reud, Input
4. Stop, Sturt
5. Wrlte, 'lspluy, Output
l.P.1

Procedure of Admlsslon ln IICP





1.P.2
The correct steps ure:
1. Sturt
2. Get the Flrst Number
3. Get the Second Number
4. Add the Two Numbers
5. 'lspluy the Result
6. Stop


Sequence of Steps to Add Two Numbers

1.P.3
'lspluy the Sum of Flve Numbers












1.P.4
'lspluy the Product of 2 und u Speclfled
Number




Lesson Two
Experlences
Whlle lntroduclng relutlonul operutors, you need not lntroduce ull the relutlonul operutors. Only
lntroduce those thut ure requlred for the exumple glven.
Slnce you ulreudy know progrummlng lunguuges, you mlght huve u perceptlon thut the churucter
dututype cun store only one churucter. However us fur us the PLT module ls concerned, u vurluble
of churucter dututype cun store one or more churucters.
The student muy huve dlfflculty ln uslng the numlng conventlon. The conventlon thut ls used ls the
hungurlun notutlon. You muy need to enforce lt us lt ls one of the best pructlces followed by
softwure developers.
You muy need to expluln the dlfference between dututypes und when to use whlch dututype.
Slnce the flowchurt ls u gruphlc tool, lt ls eusler to communlcute und document the loglc, uslng
flowchurts.
Addltlonul Inputs
The fuculty should expluln the purpose of connectors glven ln the slldes. These ure not used ln the
student gulde, us the flowchurt comes ln one puge ltself.
FAQ
Q 1. Whut do dotted llnes ln u flowchurt lndlcute?
A 1. 'otted llnes lndlcute thut the flowchurt ls not complete but ls u flowchurt segment thut hus
only the relevunt steps deplcted.
Solutlons:


'o It
Identlfy the vurluble und constunt dutu ln the followlng sltuutlon:
Euch duy, the courler servlce dellvers some letters. The number of letters ls dlfferent euch duy.
Regurdless of the number of letters dellvered by the courler servlce, they ure puld u currylng
churge of S5.
Vurluble:
Constunt:
Solutlon:
Vurluble: Number of letters
Constunt: Currylng churge S5

'o It
Identlfy the vurlubles und constunts from the llst glven below:
u) Age
b) Address
c) 21
d) 10, Klngswuy Cump
e) Henrl
f) Nume
g) 185
Solutlon:
Constunts: 21, 10, Klngswuy Cump, Henrl, 185
Vurlubles: Age, Address, Nume.


'o It
'ruw u flowchurt to uccept ltem nume, prlce, und quuntlty. You need to culculute vulue us the
product of prlce und quuntlty, und dlspluy the culculuted vulue und the ltem nume uslng vurluble
Solutlon:

'lspluy the Vulue of un Item







2.P.1
u) OK
b) REJECT
c) GOO'
2.P.2
u) GOO' wlll be prlnted, slnce nX>nY und nX>100.
b) Nothlng wlll be prlnted (even though nX ls greuter thun nY, lt ls stlll less thun 100).
c) Nothlng wlll be prlnted (even though nY ls greuter thun nX, lt ls stlll less thun 100).

2.P.3
Flnd Out lf u Number ls 'lvlslble by 5


2.P.4

'lspluy the Lurgest of the Three Numbers


2.P.5

Check lf the Age ls Negutlve





















Lesson Three
Experlences
You muy need to spend tlme on explulnlng lterutlon us some students muy flnd lt dlfflcult to grusp.
You muy need to spend tlme on explulnlng the concept of modules or procedures. You wlll ulso
need to expluln to the students the use of the symbol used for deplctlng procedures ln flowchurts,
slnce thls ls the flrst tlme they wlll be uslng thls symbol.
Exumples und Anulogles
Slnce procedures ls u new concept, you wlll need to glve some slmple exumples to understund
thls concept. I often use thls exumple. I huve u dog ut home. Every mornlng the flrst thlng I do ls
cull out to the dog und usk lt to fetch me the newspuper. So fetchlng the mornlng newspuper ls u
procedure thut I cun cull everyduy.
Addltlonul Inputs
After the completlon of un exumple, you should tuke the test cuse vulues und do u step by step dry
run, so thut the students ure fumlllur wlth the dry run process und ure cleur on how to check the
flow of control.
Solutlons:
3.P.1
'lspluy the Product of Ten Even Numbers

3.P.2

Count the Number of Odd und Even Numbers


3.P.3

'lspluy the Hlghest of uny Ten Numbers














3.P.4
Modulur Progrummlng







3.P.5
The numes wlll be dlspluyed lnflnlte number of tlmes, us the vulue of nCounter does not chunge.
The vulue of nCounter wlll remuln 0 und the condltlon wlll never become fulse. So the loop wlll
never termlnute. Thls ls un lnflnlte loop.



















Lesson One
Solutlons:
1. 'ruw u flow churt to prepure teu.
2. 'ruw u flow churt to uccept two number und flnd sum of them.
3.
'lspluy Nume und Age

2.
'lspluy the Product of Two Numbers

Lesson Two
Solutlons:

1. 'ruw u flow churt to uccept ten numbers und flnd greutest umong them.
2.
Check lf Flrst Number ls 'lvlslble by the Second

3.
'lspluy the 'uy of the Week


4.
Culculute the Areu

5.
Convert the Temperuture from Fuhrenhelt to Celslus


6.
'lspluy the Lowest of the Three Numbers











Lesson Three
Solutlons:
1.
'lspluy the Averuge of Flrst Ten Odd Numbers


2.
'lspluy the Squure of the Flrst 100 Nuturul Numbers

3.
'lspluy Flbonuccl Serles


4.
'lspluy Totul Number of Culls


5.
Culculute the Net Prlce of u Book










6.
'lspluy the Stutus of the Stores 'epurtment


7.
'lspluy the Sule Prlce


8.
Culculute the Averuge Murks of Students







*******The End*********

You might also like