Wiki

Clone wiki

moodle-filter_flowchart / Examples

Examples

Linear algorythm

\flowChart{
    st=>start: start
    in=>inputoutput: input:
    x
    op=>operation: y ← x+1
    ou=>inputoutput: output:
    y
    en=>end: end

    st->in->op->ou->en
}

Conditional

\flowChart{
    st=>start: start
    in=>inputoutput: input:
    x
    if=>condition: x≠0
    op=>operation: y ← 1/x
    ou=>inputoutput: output:
    y
    exc=>inputoutput: x=0
    en=>end: stop

    st->in->if
    if(yes)->op->ou->en
    if(no)->exc->en
}

Nested conditions

\flowChart{
    st=>start: start
    in=>inputoutput: input:
    x
    if1=>condition: x>0
    op1=>operation: y ← 1/x
    if2=>condition: x<0
    op2=>operation: y ← abs(x)
    op3=>operation: y ← x
    ou=>inputoutput: output:
    y
    en=>end: stop

    st->in->if1
    if1(yes, right)->op1->ou
    if1(no)->if2
    if2(yes, right)->op2->ou
    if2(no)->op3->ou
    ou->en
}

Postconditional loop

\flowChart{
    st=>start: start
    in=>inputoutput: input:
    x
    if=>condition: x = 0
    op=>operation: …|none
    en=>end: stop

    st->in->if
    if(yes, right)->in
    if(no)->op->en
}

Preconditional loop

\flowChart{
    st=>start: start
    op=>operation: x ← 0
    if=>condition: x=0
    in=>inputoutput: input:
    x
    bla=>operation: …|blend
    en=>end: stop

    st->op->if
    if(yes)->in(left)->if
    if(no)->bla->en
}

Counting loop

\flowChart{
    st=>start: start
    in=>inputoutput: input:
    n
    cs=>operation: i ← 0
    ce=>condition: i < n
    cb=>operation: …|blend
    ci=>operation: i ← i+1
    bla=>operation: …|blend
    en=>end: stop

    st->in->cs->ce
    ce(yes)->cb->ci(left)->ce
    ce(no)->bla->en
}

Updated