Quick Pseudocode Question (1 Viewer)

Uzername

B.S., M.S., M.A., Ph.D.
Joined
May 30, 2009
Messages
88
Gender
Male
HSC
2011
'Sup guys
firstly, the name is innovative and funny, lol 'Bored of Studies'

Anyways,
in pseudocode, there is multiway selection. (more than 2 options). Is it necessary to have a CASE ELSE statement?

examples

is this correct?

SELECT CASE choose ice cream topping
Case CHOC: select chocolate flavoured topping
Case STRAW: select strawberry flavoured topping
CASE ELSE: select no topping/do nothing
END CASE

or

SELECT CASE choose ice cream topping
Case CHOC: select chocolate flavoured topping
Case STRAW: select strawberry flavoured topping
Case NONE: select no topping for icecream.
END CASE

so it necessary for a 'CASE ELSE' statement?

Thanks verymuch.:)
 

EvoRevolution

Member
Joined
Jan 25, 2009
Messages
123
Gender
Male
HSC
2009
SELECT CASE choc topping
CASE CHOC: choose choc
CASE STRAW: choose straw
.
.
.

DEFAULT : choose none

that is how most programing is done using a DEFAULT, but for psuedocode, i was told it is not a language so u are able to make up most stuff as long as it makes sense so yes u could use CASE NONE or ELSE most teachers would understand but the best would be DEFAULT as it used in real programming and it makes sense as well
 
Joined
Mar 22, 2009
Messages
192
Gender
Male
HSC
2010
CASEWARE select
Choc : choc topping
Straw : straw topping
OTHERWISE : no topping
ENDCASE
 

Makro

Porcupine
Joined
May 16, 2006
Messages
415
Location
In between.
Gender
Male
HSC
2009
OTHERWISE is what my class has been using. It's best to do that, it just fits better than CASE NOTHING. My teacher is very pedantic with things like that. I think CASE ELSE/OTHERWISE is necessary as you're restricting the user if you're forcing them to pick a few options. Better to be safe than sorry.
 

Lazarus

Retired
Joined
Jul 6, 2002
Messages
5,965
Location
CBD
Gender
Male
HSC
2001
Check out the stickied thread on algorithms - there's a great pseudocode guide there with most of the major control methods and solutions to typical algorithm problems.
 

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

Top