Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit# 9: Computer Program Development

Similar presentations


Presentation on theme: "Unit# 9: Computer Program Development"— Presentation transcript:

1 Unit# 9: Computer Program Development

2 Learning Objectives In this unit you will be learn about: Algorithm
Problem solving tools & techniques (pseudo code, flowchart) Qualities of a good program Program life cycle

3 Algorithm Refers to the logic of a program and a step-by-step description of how to arrive at the solution of a given problem In order to qualify as an algorithm, a sequence of instructions must have following characteristics: Each and every instruction should be precise and clear Each instruction should be such that it can be performed in a finite time One or more instructions should not be repeated infinitely. This ensures that the algorithm will ultimately terminate After performing the instructions, that is after the algorithm terminates, the desired results must be obtained

4 Sample Algorithm (Example)
There are 50 students in a class who appeared in their final examination. Their mark sheets have been given to you. The division column of the mark sheet contains the division (FIRST, SECOND, THIRD or FAIL) obtained by the student. Write an algorithm to calculate and print the total number of students who passed in FIRST division.

5 Sample Algorithm (Example)
Step 1: Initialize Total_First_Division and Total_Marksheets_Checked to zero. Step 2: Take the mark sheet of the next student. Step 3: Check the division column of the mark sheet to see if it is FIRST, if no, go to Step 5. Step 4: Add 1 to Total_First_Division. Step 5: Add 1 to Total_Marksheets_Checked. Step 6: Is Total_Marksheets_Checked = 50, if no, go to Step 2. Step 7: Print Total_First_Division. Step 8: Stop.

6 Algorithm Example To calculate Average of three numbers: Algorithm:
STEP 1     START STEP 2     INPUT X,Y,Z STEP 3     COMPUTE SUM = X + Y + Z STEP 4     COMPUTE AVG = SUM/3 STEP 5     PRINT SUM STEP 6     PRINT AVG STEP 7     END

7 Flowchart Flowchart is a pictorial representation of an algorithm
Uses symbols (boxes of different shapes) that have standardized meanings to denote different types of instructions Actual instructions are written within the boxes Boxes are connected by solid lines having arrow marks to indicate the exact sequence in which the instructions are to be executed Process of drawing a flowchart for an algorithm is called flowcharting

8 Basic Flowchart Symbols

9 Examples of Decision Symbol

10 Examples of Decision Symbol

11 Sample Flowchart (Example)
Flowchart diagram to display pass or fail a student

12 Flowcharting Rules First chart the main line of logic, then incorporate detail Maintain a consistent level of detail for a given flowchart Do not chart every detail of the program. A reader who is interested in greater details can refer to the program itself Words in the flowchart symbols should be common statements and easy to understand

13 Flowcharting Rules Be consistent in using names and variables in the flowchart Go from left to right and top to bottom in constructing flowcharts Keep the flowchart as simple as possible. Crossing of flow lines should be avoided as far as practicable If a new flowcharting page is needed, it is recommended that the flowchart be broken at an input or output point. Properly labeled connectors should be used to link the portions of the flowchart on different pages

14 Advantages of Flowchart
Better Communication Proper program documentation Efficient coding Systematic debugging Systematic testing

15 Pseudocode A program planning tool where program logic is written in an ordinary natural language using a structure that resembles computer instructions “ Pseudo” means imitation or false and “ Code” refers to the instructions written in a programming language. Hence, pseudocode is an imitation of actual computer instructions Because it emphasizes the design of the program, pseudocode is also called Program Design Language (PDL)

16 Basic Logic (Control) Structures
Any program logic can be expressed by using only following three simple logic structures: 1. Sequence logic 2. Selection logic 3. Iteration (or looping) logic Programs structured by using only these three logic structures are called structured programs, and the technique of writing such programs is known as structured programming

17 Sequence Logic

18 Selection Logic Also known as decision logic, it is used for making decisions Three popularly used selection logic structures are 1. IF…THEN…ELSE 2. IF…THEN 3. CASE

19 Selection Logic (IF…THEN…ELSE Structure)

20 Selection Logic (IF…THEN Structure)

21 Selection Logic (CASE Structure)

22 Iteration (or Loping) Logic
Used to produce loops in program logic when one or more instructions may be executed several times depending on some conditions Two popularly used iteration logic structures are 1. DO…WHILE 2. REPEAT…UNTIL

23 Iteration (or Looping) Logic (DO…WHILE Structure)

24 Iteration (or Looping) Logic (REPEAT…UNTIL Structure)

25 Advantages of Pseudocode
Converting a pseudocode to a programming language is much more easier than converting a flowchart to a programming language As compared to a flowchart, it is easier to modify the pseudocode of a program logic when program modifications are necessary Writing of pseudocode involves much less time and effort than drawing an equivalent flowchart as it has only a few rules to follow

26 Qualities of a good program
A good computer program should have following qualities: Portability: Portability refers to the ability of an application to run on different platforms (operating systems) with or without minimal changes. Readability: The program should be written in such a way that it makes other programmers or users to follow the logic of the program without much effort. Efficiency: Every program requires certain processing time and memory to process the instructions and data. As the processing power and memory are the most precious resources of a computer, a program should be laid out in such a manner that it utilizes the least amount of memory and processing time.

27 Qualities of a good program
Structural: To develop a program, the task must be broken down into a number of subtasks. These subtasks are developed independently, and each subtask is able to perform the assigned job without the help of any other subtask. Flexibility: A program should be flexible enough to handle most of the changes without having to rewrite the entire program. Generality: Apart from flexibility, the program should also be general. Generality means that if a program is developed for a particular task, then it should also be used for all similar tasks of the same domain. Documentation: Documentation is one of the most important components of an application development. A well-documented application is also useful for other programmers because even in the absence of the author, they can understand it.

28 Program life cycle When we want to develop a program using any programming language, we follow a sequence of steps. These steps are called phases in program development. The program development life cycle is a set of steps or phases that are used to develop a program in any programming language. Main phases are: Problem Definition Problem Analysis Algorithm Development Coding & Documentation Testing & Debugging Maintenance

29 Program life cycle

30 Program life cycle Problem Definition:
Define the problem statement and decide the boundaries of the problem. Needs to understand the problem statement, what is requirement, what should be the output of the problem solution.

31 Program life cycle Problem Analysis:
Determine the requirements like variables, functions, etc. to solve the problem. That means we gather the required resources to solve the problem defined in the problem definition phase Algorithm Development: Develop a step by step procedure to solve the problem using the specification given in the previous phase Very important phase for program development. That means we write the solution in step by step statements.

32 Program life cycle Coding & Documentation:
This phase uses a programming language to write or implement actual programming instructions for the steps defined in the previous phase. Testing & Debugging: In this phase we test the program whether it is solving the problem for various input data values or not. We also test that whether it is providing the desired output or not. Maintenance: If the user encounters any problem or wants any enhancement, then we need to repeat all the phases from the starting, so that the encountered problem is solved or enhancement is added.


Download ppt "Unit# 9: Computer Program Development"

Similar presentations


Ads by Google