13

I'm making a flowchart a for an algorithm, and came into some problem for an else if statement.

For an if-statement such as this one

if (something) {}
else if (something) {}
else {}

How would the else if statement look like in a flowchart diagram?

starcorn
  • 8,261
  • 23
  • 83
  • 124

4 Answers4

26

http://code2flow.com allows you to create such flowcharts from code.

enter image description here

You may click to edit this.

RushPL
  • 4,732
  • 1
  • 34
  • 44
  • Thank you - I have been looking for a tool like this and it will be really useful. – KAE Aug 10 '16 at 17:44
6

Here is the DRAKON version of this:

if (case1) {outcome1}
else if (case2) {outcome2}
else {outcome3}

if and else if in DRAKON

Alternatively, it could look like this:

switch construct in DRAKON

See here: http://en.wikipedia.org/wiki/DRAKON

Stepan Mitkin
  • 161
  • 1
  • 3
1

You could diagram this as two separate if statements.

I don't know if this is the "standard" method, but that's what I do.

Brad
  • 159,648
  • 54
  • 349
  • 530
0

For starters, let's recast the statement.

if (case1) {outcome1}
else if (case2) {outcome2}
else {outcome3}

Does it not flow thus?

case1? yes --> outcome1

no --> case2? yes --> outcome2

no --> outcome3

dmerrill
  • 29
  • 1