© 2026 schoolict.net (Ruwan Mangala Suraweera)
1.2 Algorithms: Sequence, Selection and Iterationඇල්ගොරිතම: අනුක්රමය, වරණය සහ පුනරාවර්තනය
G.C.E. O/L Grade 11 ICT · Lesson 1G.C.E. O/L ICT · 11 ශ්රේණිය · පාඩම 1
In this videoමේ වීඩියෝවේ
- An algorithm is a step-by-step solution.ඇල්ගොරිතමයක් පියවරෙන් පියවර විසඳුමකි.
- Steps must be clear, in order and must finish.පියවර පැහැදිලි, පිළිවෙළට සහ අවසන් විය යුතුය.
- Sequence: steps one after another.අනුක්රමය: එකින් එක පියවර.
- Selection: choose using a condition.වරණය: කොන්දේසියක් මගින් තේරීම.
- Iteration: repeat steps.පුනරාවර්තනය: පියවර නැවත කිරීම.
Notesසටහන්
Syllabus 10.2. An algorithm is a list of clear steps, in the correct order, that solves a problem. Every algorithm – from making tea to running a bank – is built from just three control structures: sequence, selection and iteration. Learn these three and you can plan any program.විෂය නිර්දේශය 10.2. ඇල්ගොරිතමයක් යනු ගැටලුවක් විසඳන, නිවැරදි පිළිවෙළට ඇති පැහැදිලි පියවර ලැයිස්තුවකි. තේ හදන එකේ සිට බැංකුවක් පවත්වාගෙන යාම දක්වා සෑම ඇල්ගොරිතමයක්ම පාලන ව්යුහ තුනකින් පමණක් ගොඩනැගේ: අනුක්රමය (sequence), වරණය (selection) සහ පුනරාවර්තනය (iteration). මේ තුන ඉගෙන ගත් විට ඕනෑම වැඩසටහනක් සැලසුම් කළ හැක.
1. What is an algorithm?1. ඇල්ගොරිතමයක් යනු කුමක්ද?
An algorithm is a step-by-step plan. It is not yet a program – it is written in simple words, pseudocode or a flowchart. A good algorithm has: a clear start and end, steps that are clear (no guessing), steps in the correct order, and it finishes after a limited number of steps.ඇල්ගොරිතමයක් යනු පියවරෙන් පියවර සැලැස්මකි. එය තවම වැඩසටහනක් නොවේ – එය සරල වචනවලින්, ව්යාජ කේතයෙන් හෝ ගැලීම් සටහනකින් ලියනු ලැබේ. හොඳ ඇල්ගොරිතමයකට: පැහැදිලි ආරම්භයක් සහ අවසානයක්, පැහැදිලි පියවර (අනුමාන නැත), නිවැරදි පිළිවෙළ, සහ සීමිත පියවර ගණනකින් අවසන් වීම තිබිය යුතුය.
2. Sequence2. අනුක්රමය (Sequence)
In a sequence, the steps run one after another, from top to bottom, each step exactly once. Example: input three marks, find the total, find the average, display them.අනුක්රමයේදී පියවර එකින් එක, ඉහළ සිට පහළට, සෑම පියවරක්ම හරියටම එක් වරක් ක්රියාත්මක වේ. උදාහරණය: ලකුණු තුනක් ආදානය කර, එකතුව සොයා, සාමාන්යය සොයා, ඒවා පෙන්වීම.
📝 Pseudocodeව්යාජ කේතය (Pseudocode)
BEGIN INPUT M1, M2, M3 Total = M1 + M2 + M3 Avg = Total / 3 DISPLAY Total, Avg END
program Average3; var m1, m2, m3, total: integer; avg: real; begin write('Enter mark 1: '); readln(m1); write('Enter mark 2: '); readln(m2); write('Enter mark 3: '); readln(m3); total := m1 + m2 + m3; avg := total / 3; writeln('Total = ', total); writeln('Average = ', avg:0:2); end.
m1 = int(input("Enter mark 1: ")) m2 = int(input("Enter mark 2: ")) m3 = int(input("Enter mark 3: ")) total = m1 + m2 + m3 avg = total / 3 print("Total =", total) print(f"Average = {avg:.2f}")
▶ Sample runනියැදි ධාවනය · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)
Enter mark 1: 75 Enter mark 2: 68 Enter mark 3: 72 Total = 215 Average = 71.67
3. Selection3. වරණය (Selection)
In selection, the computer checks a condition (a question with a Yes/No answer) and chooses which steps to run. Example: if the mark is 35 or more, display “Pass”, otherwise display “Fail”. Selection is also called a decision.වරණයේදී පරිගණකය කොන්දේසියක් (ඔව්/නැත පිළිතුරක් ඇති ප්රශ්නයක්) පරීක්ෂා කර ක්රියාත්මක කළ යුතු පියවර තෝරා ගනී. උදාහරණය: ලකුණ 35 හෝ ඊට වැඩි නම් “Pass” ද, නැතිනම් “Fail” ද පෙන්වන්න. වරණය තීරණයක් (decision) ලෙසද හැඳින්වේ.
📝 Pseudocodeව්යාජ කේතය (Pseudocode)
BEGIN INPUT Mark IF Mark >= 35 THEN DISPLAY "Pass" ELSE DISPLAY "Fail" ENDIF END
program PassFail; var mark: integer; begin write('Enter mark: '); readln(mark); if mark >= 35 then writeln('Pass') else writeln('Fail'); end.
mark = int(input("Enter mark: ")) if mark >= 35: print("Pass") else: print("Fail")
▶ Sample runනියැදි ධාවනය 1 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)
Enter mark: 52 Pass
▶ Sample runනියැදි ධාවනය 2 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)
Enter mark: 28 Fail
4. Iteration4. පුනරාවර්තනය (Iteration)
In iteration (also called repetition or a loop), some steps are repeated again and again while a condition is true, or a fixed number of times. Example: display the numbers 1 to 5. Without a loop we would need five DISPLAY steps; with a loop we need only one.පුනරාවර්තනයේදී (පුනරාවර්තනය හෝ ලූපය ලෙසද හැඳින්වේ) කොන්දේසියක් සත්ය වන තාක් හෝ නියමිත වාර ගණනක් සමහර පියවර නැවත නැවත ක්රියාත්මක වේ. උදාහරණය: 1 සිට 5 දක්වා සංඛ්යා පෙන්වීම. ලූපයක් නැතිනම් DISPLAY පියවර පහක් අවශ්යයි; ලූපයක් සමඟ එකක් ප්රමාණවත්ය.
📝 Pseudocodeව්යාජ කේතය (Pseudocode)
BEGIN FOR i = 1 TO 5 DISPLAY i ENDFOR END
program Count5; var i: integer; begin for i := 1 to 5 do writeln(i); end.
for i in range(1, 6): print(i)
▶ Sample runනියැදි ධාවනය · same output in Pascal and PythonPascal සහ Python දෙකෙහිම එකම ප්රතිදානය
1 2 3 4 5
5. The three structures side by side5. ව්යුහ තුන එක ළඟ
| Structureව්යුහය | What happensසිදුවන දේ | Pseudocode wordsව්යාජ කේත වචන | Daily-life exampleඑදිනෙදා උදාහරණය |
|---|---|---|---|
| Sequenceඅනුක්රමය | Steps run in order, once eachපියවර පිළිවෙළින්, එක් වරක් බැගින් | INPUT, assign, DISPLAYINPUT, පැවරීම, DISPLAY | Wake up, wash, eat breakfastඅවදි වීම, මුහුණ සේදීම, උදෑසන ආහාරය |
| Selectionවරණය | A condition chooses a pathකොන්දේසියක් මාර්ගය තෝරයි | IF … THEN … ELSE … ENDIFIF … THEN … ELSE … ENDIF | If it rains, take an umbrellaවැසි නම් කුඩය ගන්න |
| Iterationපුනරාවර්තනය | Steps repeatපියවර නැවත නැවත | FOR, WHILE, REPEAT … UNTILFOR, WHILE, REPEAT … UNTIL | Run 4 rounds of the school groundපාසල් ක්රීඩාංගණය වටා වට 4ක් දිවීම |
Key Wordsප්රධාන පද
Sample Q&Aආදර්ශ ප්රශ්න සහ පිළිතුරු
1What is an algorithm?ඇල්ගොරිතමයක් යනු කුමක්ද?
2Name the three control structures.පාලන ව්යුහ තුන නම් කරන්න.
3Which structure is used to decide Pass or Fail?Pass හෝ Fail තීරණය කිරීමට භාවිත කරන ව්යුහය කුමක්ද?
4Which structure is used to display 1 to 100?1 සිට 100 දක්වා පෙන්වීමට භාවිත කරන ව්යුහය කුමක්ද?
5For marks 75, 68 and 72, what are the total and average?ලකුණු 75, 68 සහ 72 සඳහා එකතුව සහ සාමාන්යය කුමක්ද?
6Give two qualities of a good algorithm.හොඳ ඇල්ගොරිතමයක ගුණාංග දෙකක් දෙන්න.
MCQබහුවරණ ප්රශ්න
Choose the correct answer for each question.සෑම ප්රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.
1A clear, ordered list of steps that solves a problem is a/an…ගැටලුවක් විසඳන පැහැදිලි, පිළිවෙළට ඇති පියවර ලැයිස්තුවක්…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Definition of algorithm.ඇල්ගොරිතමයේ අර්ථය.
2Steps that run one after another, each once, form a…එකින් එක, එක් වරක් බැගින් ක්රියාත්මක වන පියවර…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Sequence.අනුක්රමය.
3“If it rains, take an umbrella” is an example of…“වැසි නම් කුඩය ගන්න” යනු … සඳහා උදාහරණයකි
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
A condition chooses.කොන්දේසියක් තෝරයි.
4“Run 4 rounds of the ground” is an example of…“ක්රීඩාංගණය වටා වට 4ක් දුවන්න” යනු … සඳහා උදාහරණයකි
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Repeated 4 times.4 වරක් පුනරාවර්තනය.
5Which is NOT one of the three control structures?පාලන ව්යුහ තුනෙන් එකක් නොවන්නේ කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Compilation is translating code.සම්පාදනය කේත පරිවර්තනයයි.
6A condition always has an answer of…කොන්දේසියක පිළිතුර සැමවිටම…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Yes/No = True/False.ඔව්/නැත = සත්ය/අසත්ය.
7The total of the marks 75, 68 and 72 is…ලකුණු 75, 68 සහ 72 හි එකතුව…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
75+68+72 = 215.75+68+72 = 215.
8For a mark of 28, the Pass/Fail program displays…ලකුණ 28 සඳහා Pass/Fail වැඩසටහන පෙන්වන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
28 < 35.28 < 35.
9Another name for iteration is…පුනරාවර්තනයට තවත් නමක්…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Loop / repetition.ලූපය / පුනරාවර්තනය.
10Another name for selection is…වරණයට තවත් නමක්…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Decision.තීරණය.
11An algorithm must end after a limited number of steps. This means it is…ඇල්ගොරිතමයක් සීමිත පියවර ගණනකින් අවසන් විය යුතුය. මෙයින් අදහස් වන්නේ එය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Finite.සීමිත.
12The count5 program displays how many numbers?count5 වැඩසටහන සංඛ්යා කීයක් පෙන්වයි?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
1, 2, 3, 4, 5.1, 2, 3, 4, 5.
13In Scratch, the “repeat 10” block is…Scratch හි “repeat 10” කුට්ටිය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
It repeats.එය පුනරාවර්තනය කරයි.
14In Scratch, the “if … then … else” block is…Scratch හි “if … then … else” කුට්ටිය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
It chooses.එය තෝරයි.
15Which of these is written BEFORE the program, to plan it?වැඩසටහන සැලසුම් කිරීමට එයට පෙර ලියන්නේ මින් කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Plan first.පළමුව සැලසුම.
MCQ answer keyMCQ පිළිතුරු
- B – Definition of algorithm.ඇල්ගොරිතමයේ අර්ථය.
- D – Sequence.අනුක්රමය.
- A – A condition chooses.කොන්දේසියක් තෝරයි.
- B – Repeated 4 times.4 වරක් පුනරාවර්තනය.
- A – Compilation is translating code.සම්පාදනය කේත පරිවර්තනයයි.
- C – Yes/No = True/False.ඔව්/නැත = සත්ය/අසත්ය.
- A – 75+68+72 = 215.75+68+72 = 215.
- D – 28 < 35.28 < 35.
- B – Loop / repetition.ලූපය / පුනරාවර්තනය.
- A – Decision.තීරණය.
- C – Finite.සීමිත.
- C – 1, 2, 3, 4, 5.1, 2, 3, 4, 5.
- B – It repeats.එය පුනරාවර්තනය කරයි.
- D – It chooses.එය තෝරයි.
- C – Plan first.පළමුව සැලසුම.
Structured Questionsව්යුහගත ප්රශ්න
1(i) Define an algorithm. (1 mark)
(ii) Name the three control structures and give one daily-life example of each. (6 marks)(i) ඇල්ගොරිතමයක් අර්ථ දක්වන්න. (ලකුණු 1)
(ii) පාලන ව්යුහ තුන නම් කර එක් එකකට එදිනෙදා උදාහරණයක් දෙන්න. (ලකුණු 6) (7 marksලකුණු 7)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
2Write an algorithm in simple steps to find the area of a rectangle. Which control structure does it use? (4 marks)සෘජුකෝණාස්රයක වර්ගඵලය සොයන ඇල්ගොරිතමයක් සරල පියවරෙන් ලියන්න. එය භාවිත කරන පාලන ව්යුහය කුමක්ද? (ලකුණු 4) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
3Write steps to display “Pass” if a mark is 35 or more and “Fail” otherwise. Which structure is this? (3 marks)ලකුණ 35 හෝ වැඩි නම් “Pass” සහ නැතිනම් “Fail” පෙන්වන පියවර ලියන්න. මෙය කුමන ව්යුහයද? (ලකුණු 3) (3 marksලකුණු 3)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
4Explain why a loop is better than writing DISPLAY 100 times to show the numbers 1 to 100. (2 marks)1 සිට 100 දක්වා පෙන්වීමට DISPLAY 100 වරක් ලිවීමට වඩා ලූපයක් හොඳ ඇයි? (ලකුණු 2) (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
5Write the steps for making a cup of tea. Mark one step that is selection and one that could be iteration. (4 marks)තේ කෝප්පයක් හදන පියවර ලියන්න. වරණයක් වන එක් පියවරක් සහ පුනරාවර්තනයක් විය හැකි එක් පියවරක් සලකුණු කරන්න. (ලකුණු 4) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
🎮 Game🎮 ක්රීඩා
Summary & Downloadsසාරාංශය සහ බාගත කිරීම්
Key pointsප්රධාන කරුණු
- Algorithm = clear, ordered, finite steps.ඇල්ගොරිතමය = පැහැදිලි, පිළිවෙළට, සීමිත පියවර.
- Three control structures: sequence, selection, iteration.පාලන ව්යුහ තුන: අනුක්රමය, වරණය, පුනරාවර්තනය.
- Sequence: steps one after another.අනුක්රමය: පියවර එකින් එක.
- Selection: a condition chooses the path.වරණය: කොන්දේසියක් මාර්ගය තෝරයි.
- Iteration: steps repeat (loop).පුනරාවර්තනය: පියවර නැවත නැවත (ලූපය).
- A condition is True or False.කොන්දේසියක් සත්ය හෝ අසත්ය වේ.
- Plan the algorithm before coding.කේත කිරීමට පෙර ඇල්ගොරිතමය සැලසුම් කරන්න.
- Scratch blocks use the same three structures.Scratch කුට්ටිද එම ව්යුහ තුනම භාවිත කරයි.
