0% found this document useful (0 votes)
35 views

Standard Pseudocode Policies

This document discusses pseudocode and structured English as a way to plan computer programs using plain language instead of a specific coding language. It provides examples of common programming structures like input, output, variables, conditional statements, and repetition/loops. The examples are shown in pseudocode format and then translated into traditional BASIC and Visual Basic code to demonstrate how pseudocode can be implemented in different programming languages.

Uploaded by

Abe Stefan Bacas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Standard Pseudocode Policies

This document discusses pseudocode and structured English as a way to plan computer programs using plain language instead of a specific coding language. It provides examples of common programming structures like input, output, variables, conditional statements, and repetition/loops. The examples are shown in pseudocode format and then translated into traditional BASIC and Visual Basic code to demonstrate how pseudocode can be implemented in different programming languages.

Uploaded by

Abe Stefan Bacas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Pseudocode or Structured English (Standard)

Pseudocode or Structured English is a language used to write down the steps or plan for a computer
program. There are several different varieties which all use the same structure but with slightly
different keywords. The table below shows some of the accepted KEYWORDS I will use this year
together with meaning or use and accepted combinations.

INPUT Wait for or accept data from keyboard


← Equals
+ - * / Plus, Minus, Multiply, Divide
DISPLAY Show on screen
READ Get data from disc
WRITE Put data onto disc
IF…THEN Do one or more instructions if the condition is met
ENDIF
IF…THEN Do one alternative or the other depending on whether or not
ELSE the condition is met
ENDIF
REPEAT Repeat one or more instructions until sufficient repetitions
UNTIL have occurred. (Check at end)
WHILE…DO Repeat instructions until sufficient repetitions have occurred.
ENDWHILE (Check at start)

• When we write a plan for a program in Pseudocode it should contain sufficient information so
that it can be turned into working code in any acceptable computer language such as SQL,
BASIC, Pascal, C++ etc.

• The second thing which is needed in Pseudocode, or any computer language is VARIABLES.
This allows varying data to be fed into the computer.

• In Pseudocode a variable is simply the name of a piece of data which is to be entered or


displayed on screen. I.e. INPUT date or DISPLAY total

• In older computer languages the variable is the name of the memory location where the data is
kept. i.e. PRINT num2 will display on screen the value currently in the RAM area called
num2.

• In Visual Basic we use some traditional variables but most of our varying data is ‘held in’ text
boxes. To DISPLAY a value we put it into a text box using an instruction such as
textbox1.text = ‘Hello’ or lblAnswer.caption = 23
Pseudocode examples together with BASIC and Visual Basic versions of the code.
For the sake of simplicity I have not used ‘VAL’ and ‘STR’ in the Visual Basic

Pseudocode Traditional BASIC Visual Basic


INPUT num1 INPUT Num1 Private Sub Go_Click()
Num1 ← Num1 * 2 Num1 = Num1 * txtAnswer.text = txtNum1.text * 2
DISPLAY Num1 2 End Sub
PRINT Num1 Note that the input has already been done before
the Go button is pressed. Note also that the
processing is done in the same line as the output.
INPUT X INPUT X Private Sub Go_Click()
INPUT Y INPUT Y txtZ.text = txtX.text + txtY.text
Z ← X + Y Z = X + Y End Sub
DISPLAY Z PRINT Z Note again that the numbers for X and Y must be
entered before pressing the Go button

DIM X,Y,Z as integer


Private Sub Go_Click()
X = txtX.text
Y = txtY.text
Z=X+Y
txtZ.text = Z
End Sub

This looks more like the Pseudocode and


Traditional Basic versions but is not necessary for
short simple calculations.

INPUT score INPUT score Private Sub Result_Click()


IF score > 90 IF score > 90 IF txtScore.text > 90 THEN
THEN THEN txtResult.txt = ‘Excellent’
DISPLAY PRINT END IF
‘Excellent’ ‘Excellent’ End Sub
ENDIF ENDIF
INPUT score INPUT score Private Sub Result_Click()
IF score > 49 IF score > 49 IF txtScore.text > 49 THEN
THEN THEN txtResult.txt = ‘Pass’
DISPLAY ‘Pass’ PRINT ELSE
ELSE ‘Pass’ txtResult.txt = ‘Fail’
DISPLAY ‘Fail’ ELSE
END IF
ENDIF PRINT
End Sub
‘Fail’
ENDIF
The next example shows repetition or looping. It should print the numbers from 1
to 5
X ← 1 X = 1 DIM X as integer
REPEAT REPEAT Private sub Go_Click()
DISPLAY X PRINT X X=1
X ← X + 1 X = X + 1 DO
UNTIL X = 6 UNTIL X = 6 txtOutput.text = txtOutput.text & X
X=X+1
LOOP UNTIL X = 6

You might also like