Visual Studio 2013 Lesson 37: PseudoCode

[Lesson 36] <<[Contents]>>[Lesson 38]

Pseudocode by example

  • PseudoCode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool.

    The rules of Pseudocode are reasonably straightforward. All statements showing "dependency" are to be indented. These include while, do, for, if, switch. Examples below will illustrate this notion.

    Examples:

    1..

    IF student's grade is greater than or equal to 60
    Print "passed"
    ELSE
    Print "failed"

     

    2..

    Set total to zero
    Set grade counter to one
    WHILE grade counter is less than or equal to ten

           
    INPUT from KEYBOARD the next grade
           
    Add the grade into the total
            SET the class average to the total divided by ten

           
    MESSAGE BOX class average to SCREEN

    3..

    SET total to zero
    SET counter to zero
    INPUT FROM KEYBOARD the first grade
        WHILE the user has not as yet entered the sentinel
        ADD this grade into the running total
        ADD one to the grade counter
        INPUT the next grade (possibly the sentinel)
           IF the counter is not equal to zero
                set the average to the total divided by the counter
                print the average
           ELSE
    print 'no grades were entered'
     

    4..

    Initialize passes to zero
    Initialize failures to zero
    initialize student to one
        WHILE student counter is less than or equal to ten
        input the next exam result
           IF the student passed
            add one to passes
        ELSE
            add one to failures
            add one to student counter
            print the number of passes
            print the number of failures
                IF eight or more students passed
                print "raise tuition"


    Some Keywords That Should be Used

    For looping and selection, The keywords that are to be used include

    • Do While...EndDo;

      Do Until...Enddo;

    • Case...EndCase;

    •  If...Endif;

    • Call ... with (parameters);

    • Call;

    • Return ....;

    • Return;

    • When;

    Always use scope terminators for loops and iteration.
    As verbs, use the words Generate, Compute, Process, etc. Words such as set, reset, increment

     

[Lesson 36] <<[Contents]>>[Lesson 38]