English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
1

hi i am stuck on a past paper question and i dont have a clue what it is.

3 (a) An example of an iteration in pascal is
FOR x:=1 to 10 do writeln('Hi');

Using the correct syntax give an example of:
i) declaration
ii) assignment
iii)selection

2007-12-09 18:58:05 · 4 answers · asked by Undefined 1 in Computers & Internet Programming & Design

4 answers

3 (a) An example of an iteration in pascal is
FOR x:=1 to 10 do writeln('Hi');

This writes 10 lines of

Hi


i) declaration
var ch: char;
ii) assignment
char := '9';
iii) selection
example 1:
if ch = '9' then begin
flag := true;
exit
else
flag := false;
endif
example 2:
case ch of
'0'..'9':
writeln('The character you input is a digit.');
otherwise
writeln('The character you input is not a digit.')
end

2007-12-09 19:28:01 · answer #1 · answered by JA12 7 · 0 0

You probably want the answer in Pascal and while all of the previous answers seem to give it to you I have not seen Pascal. The answer to the first question has already been answered so let get to the rest.

declaration
var i: integer;

assingment
i:=10;

selection
if (i<10) then
begin
writeln ("i is less than 10");
end;

2007-12-10 04:27:48 · answer #2 · answered by Charles R 4 · 1 0

For declaration:

VAR x: integer; (declares variable x as integer)

For Assignment:
x := 4; (Assigns value 4 to x)

For Selection:
==========

IF-ELSE-ENDIF selection
====================
IF flag THEN
WRITELN('Flag is true')
ELSE
WRITELN('Flag is false')
ENDIF

IF-ELSEIF-ELSEIF-ENDIF Selection
============================
IF grade == 'A' THEN
WRITELN('Excellent work!')
ELSEIF grade == 'B' THEN
WRITELN('You did well...');
ELSEIF grade == 'C' THEN
WRITELN('Average performance.');
ELSEIF grade == 'D' THEN
WRITELN('Needs some improvement...');
ELSEIF grade == 'E' THEN
WRITELN('Trouble ahead!');
ENDIF

2007-12-10 03:28:02 · answer #3 · answered by ngg_ghimire 2 · 0 0

i) Write a statement to declare a variable in Pascal
ii) Write an assignment statement in Pascal
iii) Write a selection statement in Pascal

2007-12-10 03:16:38 · answer #4 · answered by AnalProgrammer 7 · 0 1

fedest.com, questions and answers