![Page 1: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/1.jpg)
![Page 2: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/2.jpg)
ComputerProgramming-I
Developedby:Strawberry
![Page 3: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/3.jpg)
Objec=veofCP-I
The course will enable the students to understand the basic concepts of structured programming.
Developedby:Strawberry
![Page 4: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/4.jpg)
Whatisprogramming?• Wri=ngasetofinstruc=onsthatcomputer
usetoperformspecificopera=ons.
Developedby:Strawberry
![Page 5: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/5.jpg)
Whatisprogramminglanguage?
• Set of instructions are written in a programming language.
• Need for programming language – to communicate instructions to machine (computer).
Developedby:Strawberry
![Page 6: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/6.jpg)
Developedby:Strawberry
WhatisProgramming?
• Art of solving computational problems by computer.
• Computer is an electronic device and does not understand natural language.
• Set of symbols, characters, grammar rules that permit people to construct instructions in the format that can be interpreted by the computer system.
![Page 7: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/7.jpg)
Developedby:Strawberry
LanguageTypesTypes of Programming Languages
MachineLanguage
AssemblyLanguage
Low-levelLanguage
ProceduralLanguage
Fourth GenerationLanguages(4GLs)
Visual ProgrammingLanguages
High-levelLanguage
ProgrammingLanguages
![Page 8: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/8.jpg)
Developedby:Strawberry
LanguageGenera=onsOnthebasisofdevelopment,programminglanguagescanbedividedinto5genera=ons:
First Generation Language
Machine Language (1940 – 1950)
Second Generation Language
Assembly Language (1950 – 1958)
Third Generation Language
Procedural Languages (1958 – 1985)
Fourth Generation Language
4GLs (1985 onwards)
Fifth Generation Language
Visual/Graphic Languages (1990 onwards)
![Page 9: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/9.jpg)
Developedby:Strawberry
MachineLevelLanguage(1940-50)
• Languagecontainingbinarycode(1,0)whichthecomputercanunderstand.
• Instruc=oncontainstwoparts:– Opera=onPart–Specifieswhatistobeperformed.
– AddressPart–Specifiestheloca=onofdatatobemanipulated.
![Page 10: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/10.jpg)
Developedby:Strawberry
Advantages-MachineLanguage• Directlyexecutable.• Mostefficientuseofcomputersystem
resourceslikestorage,register,etc.
• Canbeusedtomanipulateindividualbits.
![Page 11: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/11.jpg)
Developedby:Strawberry
Disadvantages-MachineLanguage
• Not portable as device dependent.
• More error prone and difficult to debug.
• Storage locations have to be addressed directly, and not symbolically.
• Increases programmer training cost as requires a high level of programming skills.
• Requires knowledge of the computer’s intricate details.
![Page 12: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/12.jpg)
Developedby:Strawberry
AssemblyLanguage(1950-58)• Substitute alphabetic symbols for the binary codes of machine language.
• Symbols – memory locations.
• Mnemonics – operation code.
• One-to-one correspondence between assembly & machine language.
• Requires an assembler to convert assembly language into machine language.
• MVIB,06//LoadRegisterBwiththeHexvalue06
• MOVA,B//MovethevalueinBtotheAccumulatororregisterA
• MVIC,07//LoadtheRegisterCwiththesecondnumber07
• ADDC//AddthecontentoftheAccumulatortotheRegisterC
• STA8200//Storetheoutputatamemoryloca=one.g.8200
• HLT//Stoptheprogramexecu=on
![Page 13: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/13.jpg)
Developedby:Strawberry
Advantages-AssemblyLanguage• Because symbols are meaningful, it is easier to read and
understand.
• Relieves users of the problems in allocating computer storage.
• Encourages modular programming.
• Used only when efficiency is the must or when there is a need to manipulate processor registers, signals, etc.
![Page 14: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/14.jpg)
Developedby:Strawberry
Disadvantages-AssemblyLanguage• Machine-dependent and hence not portable.
• Knowledge of details of logical structure of the computer.
• Writing is difficult & time-consuming.
• Requires rigorous training.
• Not directly executable, require Assembler.
• One-to-one correspondence with machine language.
![Page 15: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/15.jpg)
Developedby:Strawberry
Assembler• A program to translate an assembly program (source code)
into its machine equivalent(object code).
• Procedure : – After the object program is created, it is transferred into
the computer’s primary memory using the system’s loader.
– Another program called link editor passes computer control to the first instruction in the object program, and then the execution starts and proceeds till the end of the program.
![Page 16: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/16.jpg)
Developedby:Strawberry
HighLevellanguages(1958….)• They are machine-independent as they relate to the
procedures being coded.
• A HLL program can be executed on any computer system that has a translator for that HLL.
• Translated into machine code by compilers & interpreters.
• Written in English-like language.
![Page 17: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/17.jpg)
Developedby:Strawberry
Advantages-HLL• Machine-independent hence portable.
• Easier to learn & requires less time to code.
• Provides better documentation.
• Libraries of subroutines can be incorporated and used in many other programs.
• Easier to debug as translators display all errors with proper error messages.
![Page 18: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/18.jpg)
Developedby:Strawberry
SomeHighLevelLanguagesFORTRAN Engineering and Scientific work COBOL Business data processing BASIC Learnt quickly by beginners, popular
among users of small computers PASCAL Used in teaching computer programming,
useful in system programs because of rich data structure representation.
SNOBOL Used in Symbol manipulation LISP Solving logical complex problems (chess,
prove theorems) ADA Complex military applications
![Page 19: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/19.jpg)
Developedby:Strawberry
TranslatorsINTERPRETER COMPILER
Translates the program line by line. Translates the entire program. Each time the program is executed, every line is checked for syntax and then converted to equivalent machine code.
Converts the entire program to machine-code, when all the syntax errors are removed, and executes the object code directly.
Source program & the interpreter are required for execution.
Neither source nor the compiler are required for execution.
Good fro fast debugging and at testing stage.
Slow for debugging and testing.
Execution time is more. Execution time is less. No security of source code. Security of source code. - Basic - C, Cobol, Pascal, Fortran
![Page 20: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/20.jpg)
ProgrammingConcepts?
• Computerrequiresinstruc=onstobegivenforanyjobtobedone.
• Studentsneedtoknowaspartofcourseandjob.
• Lateronjustamaaerofknowingthesyntax.
Developedby:Strawberry
![Page 21: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/21.jpg)
ProgramDevelopmentSteps
• Algorithm
• Flowchart• Program
In order to solve a problem using a
computer it is necessary to evolve a
detailedandprecisestepbystepmethod
ofsolu=on.
Developedby:Strawberry
![Page 22: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/22.jpg)
Algorithm
• Finitesequenceofinstruc=ons(tosolveaproblem).
• Thedevelopmentofaproperproceduretogettherequiredresults.
n Inputs
n Precise&unambiguousprocessingrules
n Basicinstruc=ons
n Finitesteps
n Outputs
Characteris=cs
Developedby:Strawberry
![Page 23: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/23.jpg)
PointsfordevelopingAlgorithm
• Every procedure should carefully specifytheinputandoutputrequirements.
• Meaning of variables should be clearly
defined.
• The flowof program should generally be
forward except for normal looping and
unavoidableinstance.
Developedby:Strawberry
![Page 24: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/24.jpg)
ExampleProblem:Obtainthepercentageofmarksobtainedbyastudentinanexamina=on.
Solu,on:I/P:Intheproblemmaximummarksandmarksobtainedisgiven.
O/P:Therequiredresultispercentageofmarksandtheformulausedis
%ofmarks=MarksobtainedX100
Maximummarks
Algorithm:Step1:Readname,marksobtained,andmaximummarks.
Step2:DividemarksobtainedbymaximummarksandstoreitinPer.
Step3:Mul=plyPer.by100togetpercentage.
Step4:Writenameandpercentage.
Step5:Stop.Developedby:Strawberry
![Page 25: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/25.jpg)
Flowchart
• Adetailedgraphwhichrepresentsstepstobe performed within the machine to
producetheneededoutput.
• Algorithmrepresentedinpictorialform.
• Requires only a few symbols in program
char=ng to indicate the necessary
opera=ons.
Developedby:Strawberry
![Page 26: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/26.jpg)
Characteris=csofFCs
• An aid in formula=ng and understandingalgorithms.
• Easyvisualrecogni=on,astandardconven=onisusedindrawingflowcharts.
• Sequencing & repe==on instruc=ons easilyvisible.
• Helps in detec=ng, loca=ng, and removingmistakes if the program fails to run tocomple=on.
• The program FC acts as a guide or blueprintduringtheprogramprepara=onphase.
Developedby:Strawberry
![Page 27: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/27.jpg)
Characteris=csofFCs….• Leadstoquickergraspofrela=onships.• Itbecomesamodelofaprogramorsystemthatcan
bebrokendownintodetailedpartsforstudy.
• Canbeusedasworkingmodelsinthedesignofnew
programsandsystems.
• ProgramDocumenta=on.
• Aidincommunica=ngthefactsofaproblemtothose
whoseskillsareneededinthesolu=on.
Developedby:Strawberry
![Page 28: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/28.jpg)
SymbolsusedinProgramFCs
• Input/Output(Parallelogram)
– UsedtorepresentI/Oopera=ons.– Havetwoflowlines,entry&exit.
• Processing(Rectangle)
– Storage&Arithme=copera=ons.
– Havetwoflowlines,entry&exit.
Symbols adopted by the American Na=onalStandardsIns=tute(ANSI).
Developedby:Strawberry
![Page 29: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/29.jpg)
• Terminal(RoundedRectangle)– UsedtoindicateSTART&STOP.– Hasasingleentryorexitline.
• Decision(Diamond)– Logic/comparisonopera=ons.
– Has one entry and at least two exit paths orbranches.
– The exits are labeled with the answers to thedecisionques=on.
• Flow(LinewithArrow)
– MostimportantinaFlowChart.
– Indicatestheflowoflogicoftheprogram.
– Alltheotherflowchartsymbolsareconnectedbytheflowline.
Developedby:Strawberry
![Page 30: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/30.jpg)
• Connector(Circle)
– Usedwhen addi=onal flow linesmight cause
confusionandreduceunderstanding.
– Twoconnectorswithiden=callabelsservethesamefunc=onasalongline.
• Predefined Process (Rectangle with
endlines)
– Certainprocessingopera=onsarerepeatedinprogramswhich are grouped into a separate
procedure.
– A single symbol replaces a number of
opera=onsthatneednotbedetailed.
EntryPoint
ExitPoint
Developedby:Strawberry
![Page 31: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/31.jpg)
Limita=onsofFCs
• Complexanddetailedchartsarelaborious
toplananddraw.
• Nostandardsdeterminingtheamountof
detailthatshouldbeincludedinachart.
Developedby:Strawberry
![Page 32: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/32.jpg)
ExampleProblem:Obtainthepercentageofmarksobtainedbyastudentinanexamina=on.
Start
Stop
Inputname,mks.,max.mks.
Per=marks/max.marks
Per=PerX100
Printname&per
Developedby:Strawberry
![Page 33: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/33.jpg)
Program
• Expresses the flow chart/algorithm in a moreprecise and concise nota=on to be fed to thecomputerforexecu=on.
• Machine-Independent : Primary objec=ve is tofacilitate a large number of people to usecomputerswithout the need to know in detailtheinternalstructureofthecomputer.
• The specifica=on of the sequence ofcomputa=ona l s t ep s i n a pa r=cu l a rprogramminglanguageistermedasaprogram.
Developedby:Strawberry
![Page 34: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/34.jpg)
ProgrammingTechniques
• LinearProgrammingWhenprogrammingstartedthesizeandscope
oftheprogramswassmall.
• StructuredProgramming Introducedas the sizeandscopeofprograms
grew, the tradi=onal linear approach to
programming made programs unstructured
anddifficulttounderstand.Developedby:Strawberry
![Page 35: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/35.jpg)
LinearProgramming
• Straighmorwardprogramming in a sequen=almanner.
• Doesnotinvolveanydecisionmaking.
Generalmodelofalinearprogram:1. Readadatavalue.2. Computeanintermediateresult.
3. Use the intermediate result to compute thedesiredanswer.
4. Printtheanswer.5. Stop.
Developedby:Strawberry
![Page 36: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/36.jpg)
StructuredProgramming
• It refers to the process in which we break theoveralljobdownintoseparatepieceofmodules.
• Digital computers can make a decision, thus
crea=ngabranchingpoint.
• Ifbranchingand loopingcanbeuse, thenmore
complex itera=ve algorithms can be developed
intocomplexprograms.
• Complex programs that make them less error
proneandeasiertodebug.
Developedby:Strawberry
![Page 37: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/37.jpg)
ChoiceofModules
• Modulesmustbechoseninsuchawaythatwe
canspecifyhowtheyaretointeract.
• Theremustbeacontactbetweeneachmodules.
• Contactsspecify:– Whatthemodulewilldo?
– Whatinputsapar=cularmoduleistoreceivefrom
thevariousothermodulesandwhatoutputsitis
requiredtoprovideforthem?
Developedby:Strawberry
![Page 38: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/38.jpg)
AdvantagesofStruct.Prog.• Decreasesthecomplexityoftheprogram.
• Allowsseveralprogrammerstocodesimultaneously.
• Allowsreuseofcommonfunc=onsacrossprograms.
• Isolateserrorshencedecreasesdebugging.• Amendmentstosinglemoduledoesnotaffecttherestofthe
program.
• Asitisastandardmethodtakesless=metowrite.
• Easynamingofmoduleshelptolocateeasilyin
documenta=on.
Developedby:Strawberry
![Page 39: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/39.jpg)
ModularDesignofPrograms
• Programisdesignedasasetofunitsreferredtoasblocksor
modules.
• Themodulesreflectalogicalflowforacomputerprogram.
• Modulesbasicallyhave:
– Input– Output– Func=on– Mechanism
– InternalData• Modulesarearrangedatdifferentlevelsintoastructured
chartandallareconnected.Developedby:Strawberry
![Page 40: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/40.jpg)
ModuleConnec=onRules
• Onlyonemoduleatthetopofthestructurecalledtherootmodule.
• Therootpassescontroldownthestructurecharttothelowerlevelmodules.Controlisalwaysreturnedtotheinvokingmoduleandafinishedmoduleshouldalwaysterminateattheroot.
• Therecannotbemorethanonecontrolrela=onshipbetweenanytwomodulesonthestructurechart.IfmoduleAinvokesmoduleB,thenBcannotinvokemoduleA.
Developedby:Strawberry
![Page 41: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/41.jpg)
Example
Structured Module Chart
Crow Sparrow
Winged
Penguin
Not_Winged
Bird
Lion
Wild
Dog
Domestic
Animal
Frog
Amphibian
Creature
Developedby:Strawberry
![Page 42: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/42.jpg)
ProgramInstruc=onTypes
• Statementstoestablishthestartofthe
program.
• Variabledeclara=on.• Programstatements(blocksofcode).
– Expressions.– ProgrammingConstructs.
Developedby:Strawberry
![Page 43: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/43.jpg)
VariableDeclara=on
• Place holders for data a programmight use ormanipulate.
• Variablesaregivennamessothatwecanassignvalues to themand refer to them later to readthevalues.
• Theyaredeclaredatthestartbecause inordertouseavariablewithinaprogram,thecompilerneedstoknowinadvancethetypeofdatathatwillbestoredinit.
• Variable typically stores value (content) of agiventype(characteris=cofthevariable).
Developedby:Strawberry
![Page 44: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/44.jpg)
VariableType
n Integer To store integer or "whole" numbers.
n Real To store real or fractional numbers (also called float to indicate a floating point number).
n Character A single character such as a letter of the alphabet or punctuation.
n String A collection of characters.
Developedby:Strawberry
![Page 45: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/45.jpg)
Expressions
• Expressionsaremadeupofacombina=onofvariables&operatorswhichactonit.
• Operatorsworkwithrespecttoprecedence&associa=vityrulessetforthelanguage.
• Someoperatorsare:
– Arithme=c(Mathema=cal)
– Logical(Boolean)– Rela=onal(Comparison)
Developedby:Strawberry
![Page 46: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/46.jpg)
Operators
• Arithme=c
– Add,Subtract,Mul=ply,Divide,Remainder.
• Logical– And,Or,Not.
• Rela=onal– Less than, Greater than, Equal to, Not equalto,Lessthanequalto,Greaterthanequalto.
Developedby:Strawberry
![Page 47: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/47.jpg)
ProgrammingConstructs
• Control statements"control"whichsec=onsofcodeinaprogramaretobeexecuted.
• TypesofControlStatementsare:
– Sequen=al - The default ordering ofexecu=on.
– Selec=on (Condi=onal) - Controls whichblock of code within several alterna=ves isexecuted.
– Itera=ve - controls howmany=mes a blockofcodeisexecuted.
Developedby:Strawberry
![Page 48: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/48.jpg)
ThankYou
Developedby:Strawberry
![Page 49: Computer Programming-I - Strawberrystrawberrydevelopers.weebly.com/.../computer_programming-i.pdf · • MVI B , 06 ... PASCAL Used in teaching computer programming, ... • Easy](https://reader031.vdocument.in/reader031/viewer/2022030412/5a9e538a7f8b9a077e8bc996/html5/thumbnails/49.jpg)