Friday, October 28, 2011

Sample Pseudocode

Hi all,

just to let you know, in terms of Pseudocode, here's an example:

---------------------------------------------------------------------------

PROGRAM ExampleProgram:

/*===================
DECLARING VARIABLES
===================*/

int X;
char Y;

/*-------------------*/

int ARRAY[N];
char ARRAY[N];

/*-------------------*/

int ARRAY[N,M];
char ARRAY[N,M];


/*===================
SELECTION
===================*/

IF (condition)
    THEN statements;
    ELSE statements;
ENDIF;

/*-------------------*/

CASE (Expression)
    Condition1: statements;
    Condition2: statements;
    Condition3: statements;
    Condition4: statements;
            :
            :
    ConditionN: statements;
ENDCASE;


/*===================
ITERATION
===================*/

WHILE (condition)
    DO statements;
ENDWHILE;

/*-------------------*/

FOR (X = 1 TO 10)
    DO statements;
ENDFOR;

/*-------------------*/

END.

---------------------------------------------------------------------------

Any of these are perfectly fine, and really any other command you like - I can't really just list all the commands that are permitted, otherwise I'd be kinda giving you the answer.

And don't forget to use CamelNotation (aka CamelCase):

No comments:

Post a Comment