Flowchart Help with Homework Equations

  • Thread starter Ronaldo95163
  • Start date
3 replies · 2K views · last reply
Ronaldo95163
Messages
77
Reaction score
1

Homework Statement


Given in the picture below, part c

Homework Equations


The Attempt at a Solution

I attempted it with a flowchart shown in the pic below as well. Not sure if what I did was correct though
 
Attachments
  • Printed exam page, Section B, Problem Solving with Computers, question 3, with parts (a) to (d) and the pseudocode algorithm in Figure 1 counting pineapples and bananas.
    flowcht.jpg
    30 KB · Views: 422
  • Handwritten flowchart on lined paper: START, then pcount = 0 and bcount = 0, a loop test j < 100, read choice, a decision 'is choice Y?', with No leading to pcount = pcount + 1 and Yes to bcount = bcount + 1, then print pcount, print bcount, and STOP.
    IMG_20140319_195209.jpg
    20.3 KB · Views: 491
Last edited by a moderator:
Ronaldo95163 said:

Homework Statement


Given in the picture below, part c


Homework Equations





The Attempt at a Solution




I attempted it with a flowchart shown in the pic below as well. Not sure if what I did was correct though
Overall it looks OK to me, but I don't remember ever seeing a flowchart symbol to represent a for loop. Is that something you've been taught? There is a lot that goes on in a for loop that gets glossed over with such a symbol, such as the initialization of the loop counter variable, the test to get out of the loop, and the incrementing of the loop counter.
 
Our teacher showed us it as an automatic counter box, The left most value represents the starter value, the right most represents the amount to increment by each time, the top most is the variable and the bottom most is the value to end at
 
Ronaldo95163 said:
Our teacher showed us it as an automatic counter box, The left most value represents the starter value, the right most represents the amount to increment by each time, the top most is the variable and the bottom most is the value to end at

That's reasonable, but I agree w/ Mark that it glosses over the real workings. It is one thing if you use a high-level language loop control that pretty much mimics that box, but if you are writing full loop control in, say, assembly language, your flowchart will not reflect what the code really looks like and may confuse you if things go wrong and you have to debug it.