Photo AI

5.1.1 Write down the line number of any line of code from the provided code segment above that implements the following: (a) Initialisation (b) Looping 5.1.2 What will be the value of iCounter after the above code has been executed? NOTE: Assume that all the variables are declared correctly and there are no errors in the code - NSC Information Technology - Question 5 - 2023 - Paper 2

Question icon

Question 5

5.1.1-Write-down-the-line-number-of-any-line-of-code-from-the-provided-code-segment-above-that-implements-the-following:--(a)-Initialisation-(b)-Looping--5.1.2-What-will-be-the-value-of-iCounter-after-the-above-code-has-been-executed?--NOTE:-Assume-that-all-the-variables-are-declared-correctly-and-there-are-no-errors-in-the-code-NSC Information Technology-Question 5-2023-Paper 2.png

5.1.1 Write down the line number of any line of code from the provided code segment above that implements the following: (a) Initialisation (b) Looping 5.1.2 What ... show full transcript

Worked Solution & Example Answer:5.1.1 Write down the line number of any line of code from the provided code segment above that implements the following: (a) Initialisation (b) Looping 5.1.2 What will be the value of iCounter after the above code has been executed? NOTE: Assume that all the variables are declared correctly and there are no errors in the code - NSC Information Technology - Question 5 - 2023 - Paper 2

Step 1

Write down the line number of any line of code that implements Initialisation

96%

114 rated

Answer

Line 1 (iCounter := 0)

Step 2

Write down the line number of any line of code that implements Looping

99%

104 rated

Answer

Line 4 (sLine := '')

Step 3

What will be the value of iCounter after the above code has been executed?

96%

101 rated

Answer

The value of iCounter after execution will be 15, as it is incremented 15 times (3 for the outer loop and 5 for the inner loop).

Step 4

Provide the output of the program after the code above has been executed.

98%

120 rated

Answer

The output of the program will be a single line consisting of 15 asterisks: '*****'.

Step 5

Rewrite the second loop (for iCol := 1 to 5 do) as a conditional loop.

97%

117 rated

Answer

Using a conditional loop, it could be expressed as:

iCol := 1;
while iCol <= 5 do
begin
  inc(iCol);
end;

This loop will continue to execute as long as iCol is less than or equal to 5.

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;