0% found this document useful (0 votes)
18 views3 pages

Pseudocode Lesson 1

The document outlines basic rules for pseudocode including using capitalized keywords, indentation, commenting with //, and declaring variables and constants. It provides examples of using arrays in pseudocode including initializing an array, reading from and writing to arrays, incrementing array values, totaling array values, and counting even and odd values in an array.

Uploaded by

The Basics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Pseudocode Lesson 1

The document outlines basic rules for pseudocode including using capitalized keywords, indentation, commenting with //, and declaring variables and constants. It provides examples of using arrays in pseudocode including initializing an array, reading from and writing to arrays, incrementing array values, totaling array values, and counting even and odd values in an array.

Uploaded by

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

Pseudocode

Some basic rules in pseudocode:

1. All keywords are written in capitals


2. Indentation is important
3. Comments are preceded by two slash: //
4. Variables and constants are declared explicitly.

Variables:

Literals and Identifiers:

DECLARE Number1 : INTEGER

DECLARE Name: STRING

Assignment: 
ARRAYS:

DECLARE Number1: ARRAY [1:7] AS INTEGER

20 10 10 60 20 30 50

Number1[1 Number1[2 Number1[3 Number1[4 Number1[5 Number1[6 Number1[7


] ] ] ] ] ] ]

Number1[3]  10

Number1 [5]  20

//Reading values from array

FOR Counter  1 TO 7

OUTPUT Number1[counter]

NEXT counter

//Storing values in array

FOR Counter  1 TO 7

INPUT Number1[counter]

NEXT counter

//Incrementing all values in array by 10 and display the updated values

FOR Counter  1 TO 7

Number1[counter]= Number1[counter]+10

OUTPUT Number1[counter]

NEXT counter
30 20 20 70 30 40 60

Number1[1 Number1[2 Number1[3 Number1[4 Number1[5 Number1[6 Number1[7


] ] ] ] ] ] ]

//Totalling all the values in the array and adding them.

FOR Counter  1 TO 7

Total Total+ Number1[counter]

NEXT Counter

OUTPUT “Total is” , Total

//Counting the even and odd values in array

DECLARE EvenCounter: INTEGER

DECLARE OddCounter: INTEGER

EvenCounter, OddCounter=0

FOR Counter  1 TO 7

IF Number1[counter]%2==0 THEN

EvenCounter

NEXT Counter

OUTPUT “Total is” , Total

You might also like