• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Pseudocode/Flowchart syntax (1 Viewer)

zvyx

Member
Joined
Aug 10, 2006
Messages
95
Location
NSW
Gender
Male
HSC
2008
I've lost my flowchart/pseudocode syntax reference bunch of sheets, so here I am with no clear definitions for the syntax.

I can only remember pseudocode:
BEGIN mainprogram
END mainprogram
IF THEN ENDIF (one or two words?)
WHILE ENDWHILE

and for flowchart;
rounded rectangle - start and end of algorithm
rectangle - process
diamond - decision

I've forgotten the rest of it, and I know there's more (like subprograms)

Cheers for anyone who can help me with a clear definition of these :)
 

Rampager

Member
Joined
Jun 4, 2008
Messages
100
Gender
Male
HSC
2008
You've pretty much got it?
Note that If can be:

IF condition THEN

action
ELSE IF condition2 THEN
other action
ELSE
another action
END IF

There are two types of loops (well, three),

(Post-test Loop or Unguarded Loop)
REPEAT
action
UNTIL condition

(Pre-test Loop or Guarded Loop)
WHILE condition
action
END WHILE

(Counted Loop)
FOR value/integer/condition
action
NEXT

Examples:

A = 6
REPEAT
A = A + 2
UNTIL A > 4
Print A
--Prints "8" as it enters the loop before checking the condition

A = 6
WHILE A < 4
A = A + 2
END WHILE
Print A
---Prints" 6" as it checks the condition before entering the loop


FOR A = 1 to 6

Print A
Next
--Enters the loop with A=1, prints "1", goes to the next value of A, which is "2", prints "2" and then keeps going until "6" is printed.



You can also slap in a "CASEWHERE" which is more or less repeated IF statements.
 

Takuto

Member
Joined
May 14, 2006
Messages
454
Location
abo town
Gender
Male
HSC
2008
A = 6
REPEAT
A = A + 2
UNTIL A > 4
Print A
--Prints "8" as it enters the loop before checking the condition
huh? are you sure? lol

it prints 8 before it checks if a > 4?
 

Rampager

Member
Joined
Jun 4, 2008
Messages
100
Gender
Male
HSC
2008
Takuto said:
huh? are you sure? lol

it prints 8 before it checks if a > 4?
No no, I mean, after it has checked for a > 4, it prints 8 :p

"Prints "8" because it enters the loop before checking the condition, hence the value of A is increased by 2 before the loop's condition is checked" thats my justification for it, ya'dig?
 

Takuto

Member
Joined
May 14, 2006
Messages
454
Location
abo town
Gender
Male
HSC
2008
Rampager said:
No no, I mean, after it has checked for a > 4, it prints 8 :p

"Prints "8" because it enters the loop before checking the condition, hence the value of A is increased by 2 before the loop's condition is checked" thats my justification for it, ya'dig?
Oh, Idig

Wording confused me =P

thanks for those quick notes though, pretty awesome
 

zvyx

Member
Joined
Aug 10, 2006
Messages
95
Location
NSW
Gender
Male
HSC
2008
cheers for the pre-test loop.
just a side note: I remember my teacher stress that there was NO counted loops in pseudocode (i.e. no FOR loops).

and is "END WHILE" and "END IF" two words or joined?

the other thing is flowchart syntax.. I haven't done a flowchart in eons (always prefer pseudocode heh); anyone care to enlighten?
 

Rampager

Member
Joined
Jun 4, 2008
Messages
100
Gender
Male
HSC
2008
Personally I love using FOR loops, they reduce the need to remember (i = i +1) :p

You'll always get the option to do either a flowchart or pseudocode, so I wouldn't stress about it (this is my way of saying I forget flowcharts as well :p)

"END WHILE" and "END IF" are two separate words.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top