How can I write pseudo code for the following diagram?

I was unable to use the do-while or while loop for the following diagram:

enter image description here

Here A, B and C are functions. How to write pseudo code for the diagram above?

EDIT: This is from my C ++ programming practice. Without "cycle B" (or "cycle A"), I can write it as the following:

Start
Input x;
while(x!=2)
{
A(); Input x;
}
C();
End

However, when "cycle B" comes in, I have no idea how to turn it on.

+3
source share
3 answers
Start;

Input x;

while(x!=2){ 

    if (x!=1){
        A();
    } else{ 
        B()
    }
    Input x;
}

C();

End

But be careful with the language used, I advise you to add hibernation between data checks (just before entering x)

+4
source

What does the program do? Explain it in English, and then write. Then you have pseudo code.

If any input
 if input is not 1 and not 2
 return a  and do more input (? dont get the diagram here ;p)
 if input is 1
 return b and more input (??)
 else if not above
 return c and end program
+2

@BaptisteGousset , , . do... while , , .

Start;
Do
{
    Input x;
    if (x equals 1)
    {
        B();
    }
    elseif(x not equal to 2)
    {
        A();
    }

} While (x not equal to 2);
C();
End;

You can also implement this with the goto statement, but goto is often considered harmful .

As a rule, there is not a single canonical "pseudo-code" answer for any flowchart - it depends on what structures you want to use and how elegantly these structures correspond to your actual task.

+2
source

All Articles