[go: up one dir, main page]

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

2024 Senior CS ZedICTHub Pascal Answers

The document provides a marking scheme for a Pascal programming exercise, including a sample program that prompts the user for two numbers. It explains key concepts such as single vs. compound statements, the difference between Write and Writeln, and the assignment vs. equality operators. Additionally, it covers program structure, variable naming rules, comments, and looping structures in Pascal.

Uploaded by

petersiwila427
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)
6 views3 pages

2024 Senior CS ZedICTHub Pascal Answers

The document provides a marking scheme for a Pascal programming exercise, including a sample program that prompts the user for two numbers. It explains key concepts such as single vs. compound statements, the difference between Write and Writeln, and the assignment vs. equality operators. Additionally, it covers program structure, variable naming rules, comments, and looping structures in Pascal.

Uploaded by

petersiwila427
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/ 3

Page 1 of 3

Name: ………………………………………………

ZED ICT HUB


Mark Scheme

This marking scheme may contain errors, please review and adjust accordingly

Pascal Program to Ask the User to Enter Two Numbers


PROGRAM AskTwoNumbers;
VAR
num1, num2: Integer;
BEGIN
Write('Enter the first number: ');
Readln(num1);
Write('Enter the second number: ');
Readln(num2);
Writeln('The numbers you entered are ', num1, ' and ', num2);
END.

2. Differences Explained

(a) A single statement and a compound statement:

 A single statement is an individual command, like Write or Readln, that performs


a single action.
 A compound statement is a set of statements grouped together within
BEGIN...END keywords, allowing multiple actions to be treated as one.

(b) Write and Writeln:

 Write outputs text or values without moving to a new line after printing.
 Writeln outputs text or values and moves the cursor to the next line, making it
useful for separating lines of output.

https://zedicthub.blogspot.com/
Page 2 of 3

(c) := and =:

 := is the assignment operator in Pascal, used to assign values to variables (e.g., a


:= 5).
 = is the equality operator, used to compare two values to check if they are the
same (e.g., if a = b then).

3. Completing the Program to Calculate the Average

L7: Read(b);
L9: average := sum / 2;
L12: END.

4. Pascal is Case Insensitive

In Pascal, keywords, variable names, and function names are not case-sensitive. This
means that identifiers like MyVar, myvar, and MYVAR would all be treated as the same
name.

5. Writing Statements in Pascal

(a) The last statement in Pascal:


END.

(b) Single-line comment in Pascal:


// This is a single-line comment

(c) Multi-line comment in Pascal:

{ This is a
multi-line comment }

https://zedicthub.blogspot.com/
Page 3 of 3

6. Program Structure and Rules for Variables in Pascal

(a) Basic program structure for Pascal:

PROGRAM ExampleProgram;
VAR
a: Integer;
BEGIN
// Program statements here
END.

(b) Two rules for naming variables in Pascal:

 Rule 1: Variable names must start with a letter.


 Rule 2: They can contain letters, digits, and underscores but cannot include
spaces or special symbols.

(c) Declaring a variable called name of data type string:


VAR name: String;

(i) Example of a keyword in Pascal:


BEGIN/Integer/Real/For/Repeat/Until/eof/end/var/const

(ii) Purpose of Writeln in Pascal:


Writeln displays text or values on the screen and then moves the cursor to a new line.

7. Looping Structures in Pascal

1. FOR
2. WHILE
3. REPEAT…UNTIL

https://zedicthub.blogspot.com/

You might also like