flowcharts so let’s say we want to express the following algorithm to print out the sum of the...

42
Flowcharts • So let’s say we want to express the following algorithm to print out the sum of the biggest and smallest of three numbers

Upload: jayson-carter

Post on 17-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Flowcharts

• So let’s say we want to express the following algorithm to print out the sum of the biggest and smallest of three numbers

START

START

Read in A, B and C

START

A>B?

Read in A, B and C

START

A>B?

Read in A, B and C

YesA>C?

START

A>B?No

Read in A, B and C

YesA>C? B>C?

START

A>B?No

Read in A, B and C

YesA>C? B>C?

Biggest = C

NoNo

START

A>B?No

Read in A, B and C

YesA>C? B>C?

Biggest = A Biggest = C

Yes

NoNo

START

A>B?No

Read in A, B and C

YesA>C? B>C?

Biggest = A Biggest = C Biggest = B

Yes Yes

NoNo

START

A>B?

No

Read in A, B and C

YesA>C? B>C?

Biggest = A Biggest = C Biggest = B

Yes Yes

No

No

A>B?

A>B?Yes

B<C?

A>B?Yes

B<C? A<C?No

A>B?

No

YesB<C? A<C?

No

No

A>B?

No

YesB<C? A<C?

Smallest = C

No

No

A>B?

No

YesB<C? A<C?

Smallest = A Smallest = C

Yes

No

No

A>B?

No

YesB<C? A<C?

Smallest = A Smallest = C Smallest = B

Yes Yes

No

No

A>B?

No

YesB<C? A<C?

Smallest = A Smallest = C Smallest = B

Yes Yes

No

No

A>B?

No

YesB<C? A<C?

Smallest = A Smallest = C Smallest = B

Yes Yes

No

No

Print Smallest + Biggest

A>B?

No

YesB<C? A<C?

Smallest = A Smallest = C Smallest = B

Yes Yes

No

No

Print Smallest + Biggest

END

Flowcharts

• So let’s say we want to express the following algorithm to print out the biggest of four numbers

START

START

Read in A, B, C and D

START

A>B?

Read in A, B, C and D

START

A>B?Yes

Read in A, B, C and D

X = A

START

A>B?NoYes

Read in A, B, C and D

X = A X = B

START

A>B?NoYes

Read in A, B, C and D

X = A X = B

START

A>B?NoYes

Read in A, B, C and D

X = A X = B

C>D?

START

A>B?NoYes

Read in A, B, C and D

X = A X = B

C>D?Yes

Y = C

START

A>B?NoYes

Read in A, B, C and D

X = A X = B

C>D?NoYes

Y = C Y = D

START

A>B?NoYes

Read in A, B, C and D

X = A X = B

C>D?NoYes

Y = C Y = D

START

A>B?NoYes

Read in A, B, C and D

X = A X = B

C>D?NoYes

Y = C Y = D

X>Y?

X>Y?Yes

Print X

X>Y?NoYes

Print X Print Y

X>Y?NoYes

Print X Print Y

X>Y?NoYes

Print X Print Y

END

Symbols

Symbols

Terminal

Input/Output Operation

Process

Decision

Connector

Module

Symbols