0

I have to create a flowchart to a C# programm and I am not very familiar with it. My problem is that I do not know if one should represent variables initialization in a flowchart and if so how should I do it. Second problem is that I am not sure about the correctness of my for loop.

Here is the flowchart I created tot a part of the programm. It would be very nice if you can tell me if that is correct and if not what should I correct.

Thank you! enter image description here

3 Answers 3

2

Flowcharts are to capture solution logic in a stable/readable form. If this is sufficient for your audience, that is all that matters. Is this for yourself or a different audience? What are the audiences expectations? Is there an established standard that they are expecting?

If it is important to your logic that the variables be initialized, then add a preparation symbol (a wide hexagon) with the initializations. If the variable initializations aren't useful, then ignore them. In this case, it does not look like credit is being used as an accumulator, so it would not be important to initialize it.

Your loop looks fine, but I believe you should have a line from the top loop structure to the bottom. You could also move the exit condition to the bottom loop symbol.

2
  • Hey, thank you! What do yu think about the for loop, expecially this part--> "i=0; i< max; i++" Do you think I should describe it in words or just use code? Commented Jan 8, 2014 at 16:05
  • It depends on your audience, and intent. If it is important to your algorithm that the loop is a for loop, the having the structure you list makes sense. If the loop type doesn't matter, then just put in your condition in words. You don't have to explicitly use the loop construct, you can make do with a conditional (diamond shape) at the end with your sentinel. Remember, the flow chart is to capture the solution, not write the code. Your implementation of the solution into code can (and probably will) be different. Commented Jan 8, 2014 at 16:19
0

I think what you've done is very nice and easy to understand. Whether or not you include variable initialization largely depend on what level of abstraction you're trying to achieve. However, I think if you're at the point of needing to show variable initializations, you might as well just write the code and present that instead. Code itself is practically just a flow chart without lines. And so I don't personally think that variable initialization is appropriate for a flow chart.

1
  • I would describe the for loop in words, personally. Commented Jan 8, 2014 at 17:41
0

About the loop: the variable i is an implementation detail. You don't really care that a variable named i goes from 0 to max-1 - you only care that the loop is being executed max times. I think it should be replaced with Repeat max times or something similar.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.