Pascal Programming v1.6
© Copyright Brian Brown/Peter Henry, 1984-1997. All rights reserved.
Last modified Best viewed in 800x600 resolution.
| Notes | Tests | Comments | Index |
Previous Page

SELF TEST 6: Arrays, pred, succ, ord, chr
This test works with forms compatible browsers only. Select your answers then click on the submit button to have your answers checked.

1. Write a Pascal statement to define an array called numbers, which is an integer array with elements ranging from 1 to 20

2. Write a Pascal statement to create an array called mynumbers, of type numbers, which was defined in 1. above

3. Write a Pascal statement which assigns the integer value 20 to element 4 of the array mynumbers, which was declared in 2. above

4. Write Pascal statements which define a packed array of characters (15 elements), called word, create a working variable of type word called myword, and then reads input from the keyboard into the array myword


	type  word = PACKED ARRAY[1..15] of char;
	var   word : myword;

	begin
		readln( myword );


	type  word = PACKED ARRAY[1..15] of integer;
	var   myword : word;

	begin
		readln( word );


	type  word = PACKED ARRAY[1..15] of char;
	var   myword : word;

	begin
		readln( myword );

5. Write Pascal statements which will sum the contents of an integer array called mynumbers, which has 20 elements numbered 1 to 20


	total := 0;
	for loop = 1 to 20 
		total := total + mynumbers[loop];


	total := 0;
	for loop := 1 to 20 do
		total := total + mynumbers[loop];


	total = 0;
	for loop = 1 to 20 
		total = total + mynumbers[loop];

6. Write a Pascal statement which will initialise a packed character array called message to the string 'Hello there!'. The array has thirteen elements

7. Write a Pascal statement to display the ASCII value of the letter 'A'

8. Write a Pascal statement to display the character represented by the ASCII value 52

9. Write a Pascal statement to display the character which follows 'F'

10. Write a Pascal statement to display the character which comes before 'Z'

To submit your comments, press this button:

To clear the form, press this button:


Previous Page
br> Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.