[go: up one dir, main page]

0% found this document useful (0 votes)
197 views2 pages

Pseudocode Solutions For Worksheets 13.1/14.1 and 13.2/14.2: © Cambridge University Press 2019

Uploaded by

Indu Lakshmi
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)
197 views2 pages

Pseudocode Solutions For Worksheets 13.1/14.1 and 13.2/14.2: © Cambridge University Press 2019

Uploaded by

Indu Lakshmi
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/ 2

Pseudocode solutions for worksheets

13.1/14.1 and 13.2/14.2


1 DECLARE List : ARRAY[0:9] OF INTEGER
DECLARE Index : INTEGER

FOR Index  0 TO 9
List[Index]  0
NEXT Index
FOR Index  0 TO 9
OUTPUT List[Index]
NEXT Index
2 DECLARE List : ARRAY[0:9] OF INTEGER
DECLARE Index : INTEGER

FOR Index  0 TO 9
List[Index]  Index + 1
NEXT Index
FOR Index  0 TO 9
OUTPUT List[Index]
NEXT Index
3 DECLARE List : ARRAY[0:9] OF INTEGER
DECLARE Index : INTEGER
DECLARE Number : INTEGER

FOR Index  0 TO 9
List[Index]  0
NEXT Index
REPEAT
INPUT Number
IF (Number >= 1) AND (Number <= 10)
THEN
List[Number - 1]  List[Number - 1} + 1
ENDIF
UNTIL Number = 0
4 DECLARE Table : ARRAY[0:4, 0:4] OF INTEGER
DECLARE Row, Column : INTEGER

FOR Row  0 TO 4
FOR Column  0 TO 4
Table[Row, Column]  0
NEXT Column
NEXT Row
FOR Row  0 TO 4
FOR Column  0 TO 4
OUTPUT Table[Row, Column]
NEXT Column
NEXT Row

© Cambridge University Press 2019


5 DECLARE Table : ARRAY[0:4, 0:4] OF INTEGER
DECLARE Row, Column : INTEGER
DECLARE X, Y : INTEGER

FOR Row  0 TO 4
FOR Column  0 TO 4
Table[Row, Column]  0
NEXT Column
NEXT Row

REPEAT
INPUT X
INPUT Y
IF (X >= 1) AND (X <= 5)
THEN
IF (Y >= 1) AND (Y <= 5)
THEN
Table[X-1, Y-1]  Table[X-1, Y-1] + 1
ENDIF
ENDIF
UNTIL X = 0
6 DECLARE MyFile : STRING
DECLARE Text : STRING
MyFile  "TextFile.txt"
OPENFILE MyFile FOR READ
WHILE NOT EOF(MyFile)
READFILE MyFile, Text
OUTPUT Text
ENDWHILE
CLOSEFILE MyFile
7 DECLARE MyFile, MyNewFile : STRING
DECLARE Text : STRING
MyFile  "TextFile1.txt"
MyNewFile  "TextFile2.txt"
OPENFILE MyFile FOR READ
OPENFILE MyFile FOR WRITE
WHILE NOT EOF(MyFile)
READFILE MyFile, Text
WRITEFILE MyNewFile, Text
ENDWHILE
CLOSEFILE MyFile
CLOSEFILE MyNewFile
8 DECLARE MyFile : STRING
DECLARE Text : STRING
MyFile  "TextFile.txt"
INPUT Text
OPENFILE MyFile FOR APPEND
WRITEFILE MyFile, Text
CLOSEFILE MyFile

© Cambridge University Press 2019

You might also like