Download presentation

1
**Representing an algorithm using Flowcharts**

Review: Algorithms are step-by-step definitions given to solve a problem

2
Flowcharts Many of us find it easier to follow steps when they are represented diagrammatically or graphically. Flowchart shapes are: terminators symbol(start or stop) process symbol(assignments, calculations) input/output symbols (read, write) decision symbol(decisions between 2 options) flow control- flow of steps connector symbol(used to connect sections of a flowchart

3
Flowchart algorithm1 Write a pseudocode algorithm and a flowchart to find and display the sum of 10 and 20 Start a10 b20 Suma + b Print Sum stop start a10 b 20 suma + b Print sum stop

4
**Flowchart algorithm2 Draw a flowchart that will read 3 numbers and find the product of the 3 numbers**

Start Read n1, n2, n3 Productn1*n2*n3 Display product stop start Read n1,n2,n3 Productn1*n2*n3 Print product stop

5
**Flowchart algorithm3 Draw a flowchart that will accept 3 numbers and find and display their average**

Start Read n1,n2,n3 Average(n1+n2+n3)/3 Write average stop start Read n1,n2,n3 Average (n1+n2+n3)/3 Write average stop

6
**Write “Enter 2 unequal numbers”**

Flowchart algorithm4 Draw a flowchart that will prompt the user to enter 2 unequal numbers and find the largest between them. start Start Write “Enter 2 unequal numbers” Read n1,n2 If n1>n2 then set largen1 else set largen2 Endif Print large stop Write “Enter 2 unequal numbers” Read n1,n2 yes Is n1>n2 no Largen1 Largen2 Write large stop

7
Flowchart algorithm4 Draw a flowchart that will prompt the user to enter 3 unequal numbers and find the smallest among them. Start Write “Enter 3 unequal numbers” Read num1,num2,num3 If num1<num2 then smallnum1 else small num2 Endif If num3<small then smallnum3 Write small stop Flowchart solution on next slide

8
**Write “enter 3 unequal numbers**

start 1 Write “enter 3 unequal numbers Is num3<small yes no Read num1,num2,num3 Smallnum3 Is num1<num2 no yes Write small For additional and more complex questions see Heinemann, page 96 (flowcharts with unbounded iteration) to page99 (flowcharts with bounded iteration) Stop Smallnum1 Smallnum2 1

9
Question A problem requires you to read 3 numbers and calculate and print the total. Construct: IPO chart Pseudocode Flowchart

Similar presentations

OK

ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that.

ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Download ppt on indus valley civilization religion Ppt on statistics and probability review Importance of water for kids ppt on batteries Ppt on training and development in india Transparent lcd display ppt online Ppt on air compressor Ppt on mathematics for class 7 Science ppt on crop production and management Ppt on gulliver's travels part 3 and 4 Ppt on christianity in india