How to picture “for” loop in block representation of algorithm

前端 未结 3 2034
既然无缘
既然无缘 2020-12-29 03:22

I have probem / strange question, i got algorithm with few \"for\" loops and now i need to do block scheme of this algorithm.

I know how to picture \"while\" loop,

相关标签:
3条回答
  • 2020-12-29 03:54

    The Algorithm for given flow chart :

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    Step :01

    • Start

    Step :02 [Variable initialization]

    • Set counter: i<----K [Where K:Positive Number]

    Step :03[Condition Check]

    • If condition True then Do your task, set i=i+N and go to Step :03 [Where N:Positive Number]
    • If condition False then go to Step :04

    Step:04

    • Stop
    0 讨论(0)
  • 2020-12-29 04:02

    Here's a flow chart that illustrates a for loop:

    Flow Chart For Loop

    The equivalent C code would be

    for(i = 2; i <= 6; i = i + 2) {
        printf("%d\t", i + 1);
    }
    

    I found this and several other examples on one of Tenouk's C Laboratory practice worksheets.

    0 讨论(0)
  • 2020-12-29 04:04

    What's a "block scheme"?

    If I were drawing it, I might draw a box with "for each x in y" written in it.

    If you're drawing a flowchart, there's always a loop with a decision box.

    Nassi-Schneiderman diagrams have a loop construct you could use.

    0 讨论(0)
提交回复
热议问题