program design and development. steps in program development define the problem –inputs, outputs,...
Post on 15-Jan-2016
218 views
TRANSCRIPT
![Page 1: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/1.jpg)
Program Design and Development
![Page 2: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/2.jpg)
Steps In Program Development
• Define the Problem– Inputs, outputs, processes
• Outline the solution– Major steps
– Major subtasks
– Major control structures (repetition loops)
– Major variables
– Mainline Logic
![Page 3: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/3.jpg)
Steps in PD Continued
• Develop Algorithm
– Using pseudocode and flowcharts
• Test Algorithm
• Code into programming language
• Run complier
• Document and maintain the program
![Page 4: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/4.jpg)
Types of Programming
• Structured/Top Down Programming– Starting with solution and working into more complex
details
• Modular Design– Grouping tasks together by function
• Structure Theorem– Elimination of GOTO, replacement with IF-THEN-
ELSE
![Page 5: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/5.jpg)
Algorithm Definition
• Lists the steps involved in accomplishing a task
• Written in simple english and not a formal document
– An algorithm must be
• Lucid, precise, and unambiguous
• Give the correct solution in all cases
• Eventually end
![Page 6: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/6.jpg)
Pseudocode
• Essentially it is structured english and formalized to look like high-level computer languages
– Statements are written in simple english
– Each instruction is written on a single line
– Keywords and indentations are used to signify control structures
– Each set of instructions is written from top to bottom with only one entry and one exit
– Groups of statements may be formed into modules and that group given a name
![Page 7: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/7.jpg)
Program Data
• Variables, constants, and literals
• Integer - 16
– Byte length - 8
– Short integer - 32
– Long integer - 64
• Real
– Float – single precision
– Double – double precision
• Character
• Boolean
![Page 8: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/8.jpg)
Data Structures
• Record
• File
• Array
• String
![Page 9: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/9.jpg)
Basic Computer Operations
• A computer can receive information
– “READ” and “GET”
• A computer can put out information
– “PRINT”, “WRITE”, “PUT”, “OUTPUT”, and “DISPLAY”
• A computer can perform arithmetic actions
– + for ADD
– - for SUBTRACT
– * for MULTIPLY
– / for DIVIDE
– () for PARENTHESES
![Page 10: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/10.jpg)
Basic Computer Options Cont.
• A computer can assign a value to a variable or memory– To give an initial value use “INITALISE” or “SET”
– To assign a value use ‘=‘
– To keep a piece of information for later use ‘SAVE’ or ‘STORE’
• A computer can compare variables and select one of two alternative actions– Use of IT THEN and ELSE
– Actually it can select multiple actions
• A computer can repeat a group of actions– DOWHILE
![Page 11: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/11.jpg)
The Structure Theorem
• Sequence– The straightforward listing of each step
• Selection– The presentation of a condition and the choice
between two actions
• Repetition– The presentation of a set of instructions to be
performed repeatedly as long as a condition is true
![Page 12: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/12.jpg)
Developing An Algorithm
• Defining the Problem
– Input
– Output
– Processing
• Use Meaningful Name
![Page 13: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/13.jpg)
Designing an Algorithm
• Begin with a rough sketch of steps required to solve the problem
• Use these requirements and structure theorem to establish how the processing will take place
• It is important to not start coding until the necessary steps of defining the problem and designing the solution algorithm have been solved.
![Page 14: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/14.jpg)
Checking an Algorithm
• Choose simple input test case
• Establish what the expected result should be
• Make a table of relevant variable names
• Walk through the test case
• Continue the process until the algorithm is correct
![Page 15: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/15.jpg)
Selection Control Structures
• Used to illustrate a choice between two or more actions
• Simple IF statement
• Simple selection with null false branch (null ELSE statement)
• Combined selection (IF/AND)
• Nested IF Statement
– Linear nested IF statement
![Page 16: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/16.jpg)
The CASE Structure
• Another way of expressing a linear nested IF statement
• Can often appear cumbersome
![Page 17: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/17.jpg)
Repetition Control Structures
• Developed because many programs require the same logic to be repeated for several sets of data.
• Example– DOWHILE condition p is true
• Statement block
– ENDO
![Page 18: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/18.jpg)
DOWHILE Loop Processing
• The logical condition p is tested
• If condition p is found to be true, the statements listed in the statement block will be executed once. Control is returned to the retesting of condition p.
• If condition p is found to be false, control passes to the next statement after ENDDO and no further processing takes place within the loop.
![Page 19: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/19.jpg)
Two important DOWHILE considerations
• Testing of the condition is done at the beginning of the loop.
• The only way to terminate the loop is to render the DOWHILE consideration false.
![Page 20: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/20.jpg)
REPEAT_UNTIL Structure
• Is the exact opposite of the DOWHILE
• Condition is checked at the end as opposed to the beginning
• Counted repetition
• Question—is any method better than another?
![Page 21: Program Design and Development. Steps In Program Development Define the Problem –Inputs, outputs, processes Outline the solution –Major steps –Major subtasks](https://reader036.vdocument.in/reader036/viewer/2022062518/56649d4c5503460f94a29f34/html5/thumbnails/21.jpg)
Time for Practice