Hi, could someone to direct me the right way with this? Here is the problem, which I think I have nailed:

before:

A
	 if c then goto X
	 B
	 if d then goto Y
	 C
X:	 D
	 E
Y:	 F

after (in pseudocode):

A
if c then
  D
  E
else
  B
  if not d then
    C
    D
    E
F

Now I have a trouble with the flowchart I have attached.

Here is a pseudocode that I figured out, and I know it is wrong:

A
while c
  B
  if not d
    E
  else
    need to break out of wile loop somehow to get to 'F'
F

Please let me know if the first problem is right, and if you could help me with how to tame the flowchart to get rid of the arrow from d to F...

Thanks in advance,

Waldis :confused:

First 2 are correct. last pseudocode is wrong.
I think it needs to be something like

A
if not c then b
while not d
{
   if not c then c
   D
   E
}
F

sorry should not be a while loop just another if statement

A
if not c then b
if not d
{
   if not c then c
   D
   E
}
F

Thanks for your input.

Now I got completely confused... from c down ir TRUE, and from d down is FALSE.

By saying c after 'if not c then' do you mean setting c to TRUE? And by D you mean d, and setting it's value to TRUE?

You made my brain boil, but I didn't get anywhere...

Thanks for your help,

Waldis

I think we both got confused. I wasnt too sure what A B C etc meant. Are they states in a state machine? Or just processes? also do they run though the flow once or keep repeating? I thought they might be function calls or something . So the if not c then c meant if your c flag hasnt been set then do c.

I think i am with you now. i was confused between c and C and d and D. i take it A B C D E and F are some processes/functions etc. and c and d are flags?

In which case my pseudocode needs a minor modification i think

A
if not c then B
if not d
{
   if not c then C
   D
   E
}
F

There is no 'C' or 'D', only 'c' and 'd', which are flags. A, B, E, and F are processes. When 'A' gets down to 'c' and flags it TRUE, it goes to 'B', if FALSE goes to 'F'. If we get to 'B' the next stop is a flag 'd', and if 'd' is TRUE it exits to 'F', if 'd' is FALSE it goes to 'E' and from 'E' goes back to the flag 'c' for another round if 'c' gets flagged TRUE.
The instructions was to modify the flowchart so the pseudocode could be written without GOTOs. And as I see the problem here is either the flag 'c' on the FALSE side or the flag 'd' on the TRUE side.

I hope I'm making sense here... and thanks for bearing with me.

Ok now i am totally lost. Your initial post had c and C and d and D but now you say there is no C or D? Your initial post also said if c is true to skip B but now you are saying if c is true to do B? Lets start again. I am with you that A B E F are processes and c & d are flags. Where do they get set? does the whole thing repeat?

There were two problems at the beginning. The first problem was the code with GOTOs and the solution that I wrote was the second code I included. Then I have the second problem, for which I attached the scanned image of the flowchart I'm having problem with. What I'm talking about (with no C and D, only c and d) is this second problem from the flowchart.

And you said that the first problem, as I understood, is correct.

Ok, here is my solution for it:

A
i=TRUE
while c AND i
  if d then
    i=FALSE
  else
    E
F

All I had to do was add an additional flag where 'c' is, and if 'd' becomes FALSE, just skip 'E' and join the arrow going back to 'c', instead of going straight to 'F'.

I hope I'm making sense...

Waldis ;)

you missed out B!
Try
A
While c or not d
(
B
if not d then do E
)
F

which is almost the same as yours except i included the B (no biggie) and no extra variable needed hence performance should be marginally better.

Yup, I did miss out 'B' (I guess I should blame my keyboard, how bad it is, etc., but I won't)

What if 'c' is FALSE and 'd' is FALSE, it will go to 'B' insted of 'F' where it should...

Would this work:

A
while c AND not d
  B
  if not d then
    E
F

yeah, but if 'c' is TRUE and 'd' is TRUE, instead of going to 'B' this time it'll go to 'F'...

no because your chart says if it is not c then it can go to F without worrying about d. I had the c AND not d and changed it. Which means it is While not(not c or d) Thats dragged up some old De Morgans Theorum from years back then :D At least i think it is his (change ands to ors and ors to ands, not each individual and then not the lot)

Thanks for your help, it starts clicking in, I just need to keep keeping on with these problems and one day it'll click in and stay ;)

Waldis ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.