Flow Chart Flow Chart A flow chart is

  • Slides: 14
Download presentation
Flow Chart

Flow Chart

Flow Chart • A flow chart is a graphical or symbolic representation of a

Flow Chart • A flow chart is a graphical or symbolic representation of a process. • Each step in the process is represented by a different symbol and contains a short description of the process step. • The flow chart symbols are linked together with arrows showing the process flow direction.

Flow Chart • This diagrammatic representation can give a step-by-step solution to a given

Flow Chart • This diagrammatic representation can give a step-by-step solution to a given problem. • Data is represented in the boxes, and arrows connecting them represent flow / direction of flow of data. • Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields

Flow Chart – shows logic of an algorithm – emphasizes individual steps and their

Flow Chart – shows logic of an algorithm – emphasizes individual steps and their interconnections – e. g. control flow from one action to the next

Flow Chart

Flow Chart

 • Example Flow Chart START Step 1: Step 2: Step 3: Input M

• Example Flow Chart START Step 1: Step 2: Step 3: Input M 1, M 2, M 3, M 4 GRADE (M 1+M 2+M 3+M 4)/4 N IS GRADE<50 Y PRINT “FAIL” PRINT “PASS” STOP Input M 1, M 2, M 3, M 4 GRADE (M 1+M 2+M 3+M 4)/4 if (GRADE <50) then Print “FAIL” else Print “PASS” endif

Flow Chart Write an algorithm and draw a flowchart that will read the two

Flow Chart Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Pseudocode • Input the width (W) and Length (L) of a rectangle • Calculate the area (A) by multiplying L with W • Print A

Flow Chart Algorithm • Step 1: Input W, L • Step 2: A L

Flow Chart Algorithm • Step 1: Input W, L • Step 2: A L x W • Step 3: Print A START Input W, L A Lx. W Print A STOP

Flow Chart • Write an algorithm that reads two values, determines the largest value

Flow Chart • Write an algorithm that reads two values, determines the largest value and prints the largest value with an identifying message. ALGORITHM Step 1: Input VALUE 1, VALUE 2 Step 2: if (VALUE 1 > VALUE 2) then MAX VALUE 1 else MAX VALUE 2 endif Step 3: Print “The largest value is”, MAX

Flow Chart START Input VALUE 1, VALUE 2 Y N is VALUE 1>VALUE 2

Flow Chart START Input VALUE 1, VALUE 2 Y N is VALUE 1>VALUE 2 MAX VALUE 1 MAX VALUE 2 Print “The largest value is”, MAX STOP

Flow Chart • Example 11: Write down an algorithm and draw a flowchart to

Flow Chart • Example 11: Write down an algorithm and draw a flowchart to find and print the largest of N (N can be any number) numbers. Read numbers one by one. Verify your result by a trace table. (Assume N to be 5 and the following set to be the numbers {1 4 2 6 8 })

Flow Chart • • • Step 1: Step 2: Step 3: Step 4: Step

Flow Chart • • • Step 1: Step 2: Step 3: Step 4: Step 5: • Step 6: • Step 7: • Step 8: • Step 9: Input N Input Current Max Current Counter 1 While (Counter < N) Repeat steps 5 through 8 Counter + 1 Input Next If (Next > Max) then Max Next endif Print Max

Flow Chart START Input N, Current Max Current Counter 1 Counter < N N

Flow Chart START Input N, Current Max Current Counter 1 Counter < N N Y Print Max Counter +1 Input Next >Max Y Max Next STOP N

Flow Chart Step 1 Step 2 Step 3 Step 4 Step 5 Step 6

Flow Chart Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 5 Step 9 N Current Max Counter < N Next > Max 5 5 5 5 5 5 1 1 1 1 1 1 1 4 4 4 4 6 6 8 8 1 1 2 2 3 3 4 4 5 5 T T T T F F 4 4 2 2 6 6 8 8 8 T F F F T T F 8 output