Upcoming SlideShare
×

# Chapter 2 representation of algorithms 2

2,168 views

Published on

Published in: Business, Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

### Chapter 2 representation of algorithms 2

1. 1. Flowcharting IT 12 | Fundamentals of Programming and Database Theory and Applications Ms. Jennifer O. Calleja | IT Instructor
2. 2. Objectives <ul><li>Upon completion of this chapter, you should be able to: </li></ul><ul><ul><ul><li>• Know the main steps for problem solving. </li></ul></ul></ul><ul><ul><ul><li>• Define term flowchart. </li></ul></ul></ul><ul><ul><ul><li>• List and discus advantages and disadvantages of flowchart as a logic development tool. </li></ul></ul></ul><ul><ul><ul><li>• Solve word problems using flowcharts. </li></ul></ul></ul>Ms. Jennifer O. Calleja | IT Instructor
3. 3. Steps in Problem solving <ul><li>The first step in problem solving is to define the problem. The problem statement should be examined carefully to fully determine what question should be answered. </li></ul><ul><ul><ul><li>For example, consider this problem. A farmer had 100 chicken and all but 20 of them died. How many chicken does the farmer have left? </li></ul></ul></ul>Ms. Jennifer O. Calleja | IT Instructor
4. 4. Steps in Problem solving <ul><li>2. After the problem is defined, the next step is to assemble all given data and to assign variable names to those quantities which are unknown. </li></ul><ul><ul><li>example: </li></ul></ul><ul><ul><li>Like the following statement: </li></ul></ul><ul><ul><li>Let r = the radius of the circle </li></ul></ul>Ms. Jennifer O. Calleja | IT Instructor
5. 5. Steps in Problem solving <ul><li>3. Next, all unnecessary information should be discarded. Many problems contain information which has no meaning to the solution. </li></ul><ul><ul><li>Consider this problem: </li></ul></ul><ul><ul><li>A man received a check for 300 thousand pesos of which he deposited 120 thousand pesos into his account. If his account balance was 200 thousand pesos after this deposit, how much was his balance before the deposit? </li></ul></ul>Ms. Jennifer O. Calleja | IT Instructor
6. 6. Steps in Problem solving <ul><li>4. The next step is to discover relationships between the data express these relationships as equations. </li></ul>Ms. Jennifer O. Calleja | IT Instructor
7. 7. Steps in Problem solving <ul><li>For example, read the radius of the circle from the keyboard then find its area and circumference. </li></ul><ul><ul><ul><li>Let R = the radius of the circle </li></ul></ul></ul><ul><ul><ul><li>Let A = the area of the circle </li></ul></ul></ul><ul><ul><ul><li>Let C = the circumference of the circle </li></ul></ul></ul><ul><ul><ul><li>Thus, </li></ul></ul></ul><ul><ul><ul><li>A = π * r * r </li></ul></ul></ul><ul><ul><ul><li>C = 2 * π * r </li></ul></ul></ul><ul><ul><ul><li>Represents the relationships in the problem </li></ul></ul></ul>Ms. Jennifer O. Calleja | IT Instructor
8. 8. Steps in Problem solving <ul><li>5. The final step of problem solving is to arrange the equations into an algorithm. After the algorithm is established, the actual procedures may be executed by either the computer or manually. </li></ul>Ms. Jennifer O. Calleja | IT Instructor
9. 9. Flowchart <ul><li>a tool developed in the computer industry, for showing the steps involved in a process. </li></ul><ul><li>A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows - each shape represents a step in the process, and the arrows show the order in which they occur. </li></ul>Ms. Jennifer O. Calleja | IT Instructor
10. 10. Flowcharting Symbols Ms. Jennifer O. Calleja | IT Instructor Process Indicates any type of internal operation inside the Processor or Memory Input|output Used for any Input / Output (I/O) operation. Indicates that the computer is to obtain data or output results
11. 11. Flowcharting Symbols Ms. Jennifer O. Calleja | IT Instructor Decision Used to ask question that can be answered by True or false | yes or no connector Allows the flowchart to be drawn without intersecting lines or without a reverse flow
12. 12. Flowcharting Symbols Ms. Jennifer O. Calleja | IT Instructor Terminal Indicates the starting or ending of the program process or interrupt program Flow lines Shows direction of flow
13. 13. General Rules for Flowcharting <ul><li>The flowchart should be clear, neat and easy to follow. </li></ul><ul><li>The usual direction of the flow of a procedure or a system is from left to right or top to bottom. </li></ul><ul><li>Only one flow line should come out or from a process symbol. </li></ul>Ms. Jennifer O. Calleja | IT Instructor
14. 14. General Rules for Flowcharting <ul><li>Only one flow line should enter a decision symbol, but two or three flow lines, one for each possible answer, should leave the decision symbol. </li></ul><ul><li>Only one flow line is used in conjunction with terminal symbol. </li></ul>Ms. Jennifer O. Calleja | IT Instructor
15. 15. General Rules for Flowcharting <ul><li>All boxes of the flowchart are connected with arrows </li></ul><ul><li>Flowchart symbols have an entry point on the top of the symbol with no other entry points. The exit point for all flowchart symbols is on the bottom except for the DECISION SYMBOL. </li></ul><ul><li>The Decision Symbol has two exit points; these can be on the sides or the bottom and one side. </li></ul>Ms. Jennifer O. Calleja | IT Instructor
16. 16. Advantages of Flowcharting <ul><li>Good way of Communicating </li></ul><ul><li>Effective analysis </li></ul><ul><li>Proper documentation </li></ul><ul><li>Efficient coding </li></ul><ul><li>Proper debugging </li></ul><ul><li>Efficient program maintenance </li></ul>Ms. Jennifer O. Calleja | IT Instructor
17. 17. <ul><li>Draw a flowchart to find the sum of first 10 natural numbers. </li></ul><ul><li>This means that we want to find sum where sum is given by: </li></ul><ul><li>Sum = 1 + 2 + 3 + ………………… 9 + 10. </li></ul>Ms. Jennifer O. Calleja | IT Instructor
18. 18. Pseudocode <ul><li>is one of the tools that can be used to write a preliminary plan that can be developed into a computer program </li></ul><ul><li>a generic way of describing an algorithm without use of any specific programming language syntax. </li></ul>Ms. Jennifer O. Calleja | IT Instructor