# If-Else Flow-chart Question

• 02-09-2009
Cell
If-Else Flow-chart Question
Hey guys,

I am trying to create a flow chart and I am sort of stuck on something that should be simple.

In an If-Else flow, are the diamonds in parallel? I don't think so.

For example:

Code:

if(n < 5){
function1
function2
}
else if(n < 50){
function3
function4
}
else if(n < 500){
function5
function6
}

I don't know how to express this in a flow-chart. If I express each if statement serially on the chart, then I have to include the follow functions in the flow and that says to my mind that each function is executed.

However, is each function supposed to be executed if the If-Else statements are phrased like this? If n is less than 5, it is less than 50 and thus less than 500.

Lets say n = 4. Therefore, the first if statement is true. Does the program jump away from this If-Else structure or does it continue to the next 'else if' statement since that one is true also??

I'm assuming that it will be caught by the first if statement and then the rest of the 'else if' statements are skipped. If n = 25, then it will fail the first if statement and move to the next 'else if' statement. This is what I do not know how to express in the flow chart!

Why not just just do a bunch of 'if' statements here? What is the reasoning behind the else ifs?

• 02-09-2009
Cell
Well, I think I figured out the flow-chart question:
• 02-09-2009
matsp
Something like this?
Code:

!
!
^
/ \
/  \
/    \ Yes
!  n<5  !--------( function1, function2 )----+
\    /                                      !
\  /                                      !
\ /                                      !
v                                        !
! No                                    !
!                                        !
!                                        !
^                                        !
/ \                                      !
/  \                                      !
/    \ Yes                                !
! n<50  !--------( function3, function4 )----+
\    /                                      !
\  /                                      !
\ /                                      !
v                                        !
! No                                    !
!                                        !
!                                        !
^                                        !
/ \                                      !
/  \                                      !
/    \ Yes                                !
! n<500 !--------( function5, function6 )----+
\    /                                    !
\  /                                      !
\ /                                      !
v                                        !
! No                                    !
+----------------------------------------+
!

--
Mats
• 02-09-2009
Cell
Looks like we ended up with the same idea. I used your format, as it is much neater.

Thanks!