Selection: If–EndIf, If–Else–EndIf and Case – Grade 11 ICT Notes 1.6

© 2026 schoolict.net (Ruwan Mangala Suraweera)

1.6 Selection: If–EndIf, If–Else–EndIf and Caseවරණය: If–EndIf, If–Else–EndIf සහ Case

G.C.E. O/L Grade 11 ICT · Lesson 1G.C.E. O/L ICT · 11 ශ්‍රේණිය · පාඩම 1

Prints all tabs in the language you are reading. Use “Save as PDF” in the print window to keep a copy.ඔබ කියවන භාෂාවෙන් සියලු tabs මුද්‍රණය වේ. පිටපතක් තියාගන්න print window එකේ “Save as PDF” තෝරන්න.
🎬Video coming soon in this language. Switch language to watch the other video.මේ භාෂාවෙන් වීඩියෝව ඉක්මනින් එනවා. අනෙක් වීඩියෝව බලන්න භාෂාව මාරු කරන්න.

In this videoමේ වීඩියෝවේ

  • Selection chooses a path with a condition.වරණය කොන්දේසියකින් මාර්ගයක් තෝරයි.
  • IF … THEN runs only when True.IF … THEN True නම් පමණක් ධාවනය වේ.
  • IF … ELSE chooses one of two paths.IF … ELSE මාර්ග දෙකෙන් එකක් තෝරයි.
  • ELSE IF ladder for many ranges (grades).පරාස බොහොමයකට ELSE IF පඩිපෙළ (ශ්‍රේණි).
  • CASE chooses by a value (day number).CASE අගයක් අනුව තෝරයි (දින අංකය).
IFELSEELSE IFCASEConditionPathGrade

Notesසටහන්

Syllabus 10.6. Selection lets a program make decisions. There are three forms: If–EndIf (do something only when a condition is true), If–Else–EndIf (choose between two paths) and Case (choose one of many options). For each one we go flowchart → pseudocode → Pascal and Python code.විෂය නිර්දේශය 10.6. වරණය මගින් වැඩසටහනකට තීරණ ගත හැක. ආකාර තුනක් ඇත: If–EndIf (කොන්දේසිය සත්‍ය වූ විට පමණක් යමක් කිරීම), If–Else–EndIf (මාර්ග දෙකකින් එකක් තේරීම) සහ Case (විකල්ප බොහොමයකින් එකක් තේරීම). එක් එකක් සඳහා ගැලීම් සටහන → ව්‍යාජ කේතය → Pascal සහ Python කේතය ලෙස යමු.

1. If–EndIf (one-way selection)1. If–EndIf (ඒක-මාර්ග වරණය)

If the condition is True, the statements inside run. If it is False, they are skipped and the program continues after ENDIF.කොන්දේසිය සත්‍ය නම් ඇතුළත ප්‍රකාශ ක්‍රියාත්මක වේ. අසත්‍ය නම් ඒවා මඟ හැරී ENDIF ට පසුව වැඩසටහන දිගටම යයි.

StartCondition?StatementsYesNoStop
General form of If–EndIfIf–EndIf හි සාමාන්‍ය ආකාරය

📝 General pseudocodeසාමාන්‍ය ව්‍යාජ කේතය

IF condition THEN
  statements
ENDIF

Example: a shop in Galle gives a 10% discount when the bill is more than Rs. 5000.උදාහරණය: ගාල්ලේ කඩයක් බිල රු. 5000 ට වැඩි විට 10% වට්ටමක් දෙයි.

📝 Pseudocodeව්‍යාජ කේතය (Pseudocode)

BEGIN
  INPUT Total
  Discount = 0
  IF Total > 5000 THEN
    Discount = Total * 10 / 100
  ENDIF
  DISPLAY Discount, Total - Discount
END
StartINPUT TotalDiscount = 0Total > 5000?Discount = Total * 10 / 100YesNoDISPLAY Discount, Total – DiscountStop
Flowchart – If–EndIf: 10% discount on a bill over Rs. 5000ගැලීම් සටහන – If–EndIf: Rs. 5000 ට වැඩි බිලකට 10% වට්ටම
💻 If–EndIf: 10% discount on a bill over Rs. 5000If–EndIf: Rs. 5000 ට වැඩි බිලකට 10% වට්ටම
program BillDiscount;
var
  total, discount: integer;
begin
  write('Enter bill total (Rs.): ');
  readln(total);
  discount := 0;
  if total > 5000 then
    discount := total * 10 div 100;
  writeln('Discount = Rs. ', discount);
  writeln('Amount to pay = Rs. ', total - discount);
end.
total = int(input("Enter bill total (Rs.): "))
discount = 0
if total > 5000:
    discount = total * 10 // 100
print("Discount = Rs.", discount)
print("Amount to pay = Rs.", total - discount)

▶ Sample runනියැදි ධාවනය 1 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter bill total (Rs.): 6500
Discount = Rs. 650
Amount to pay = Rs. 5850

▶ Sample runනියැදි ධාවනය 2 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter bill total (Rs.): 3000
Discount = Rs. 0
Amount to pay = Rs. 3000

2. If–Else–EndIf (two-way selection)2. If–Else–EndIf (ද්වි-මාර්ග වරණය)

Exactly one of two groups of statements runs: the THEN part if the condition is True, the ELSE part if it is False.ප්‍රකාශ කණ්ඩායම් දෙකෙන් හරියටම එකක් ක්‍රියාත්මක වේ: කොන්දේසිය සත්‍ය නම් THEN කොටස, අසත්‍ය නම් ELSE කොටස.

StartCondition?Statements AYesStatements BNoStop
General form of If–Else–EndIfIf–Else–EndIf හි සාමාන්‍ය ආකාරය

📝 General pseudocodeසාමාන්‍ය ව්‍යාජ කේතය

IF condition THEN
  statements A
ELSE
  statements B
ENDIF

📝 Pseudocodeව්‍යාජ කේතය (Pseudocode)

BEGIN
  INPUT N
  IF N MOD 2 = 0 THEN
    DISPLAY "Even"
  ELSE
    DISPLAY "Odd"
  ENDIF
END
StartINPUT NN MOD 2 = 0?DISPLAY “Even”YesDISPLAY “Odd”NoStop
Flowchart – If–Else–EndIf: even or oddගැලීම් සටහන – If–Else–EndIf: ඉරට්ටේ හෝ ඔත්තේ
💻 If–Else–EndIf: even or oddIf–Else–EndIf: ඉරට්ටේ හෝ ඔත්තේ
program EvenOdd;
var
  n: integer;
begin
  write('Enter a number: ');
  readln(n);
  if n mod 2 = 0 then
    writeln(n, ' is even')
  else
    writeln(n, ' is odd');
end.
n = int(input("Enter a number: "))
if n % 2 == 0:
    print(n, "is even")
else:
    print(n, "is odd")

▶ Sample runනියැදි ධාවනය 1 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter a number: 14
14 is even

▶ Sample runනියැදි ධාවනය 2 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter a number: 7
7 is odd
💡 Pascal trap: never put a semicolon before else. Write writeln(‘even’) else … not writeln(‘even’); else … – the semicolon ends the whole if statement and the compiler gives an error. Python instead uses a colon : and indentation (4 spaces).Pascal උගුල: else ට පෙර කිසි විටෙක semicolon දමන්න එපා. writeln(‘even’) else … ලෙස ලියන්න, writeln(‘even’); else … ලෙස නොවේ – semicolon එක මුළු if ප්‍රකාශයම අවසන් කරන නිසා සම්පාදකය දෝෂයක් දෙයි. Python ඒ වෙනුවට colon : සහ ඉන්ඩෙන්ටේෂන් (හිස්තැන් 4) භාවිත කරයි.

3. Many choices: IF … ELSE IF (O/L grades)3. විකල්ප බොහොමයක්: IF … ELSE IF (O/L ශ්‍රේණි)

When there are more than two paths, we check conditions one after another. The first True condition wins and the rest are skipped. Sri Lankan O/L grades: A ≥ 75, B ≥ 65, C ≥ 50, S ≥ 35, otherwise W.මාර්ග දෙකකට වඩා ඇති විට, කොන්දේසි එකින් එක පරීක්ෂා කරමු. පළමු සත්‍ය කොන්දේසිය ජය ගන්නා අතර ඉතිරිය මඟ හැරේ. ශ්‍රී ලංකා O/L ශ්‍රේණි: A ≥ 75, B ≥ 65, C ≥ 50, S ≥ 35, නැතිනම් W.

📝 Pseudocodeව්‍යාජ කේතය (Pseudocode)

BEGIN
  INPUT Marks
  IF Marks >= 75 THEN
    Grade = "A"
  ELSE IF Marks >= 65 THEN
    Grade = "B"
  ELSE IF Marks >= 50 THEN
    Grade = "C"
  ELSE IF Marks >= 35 THEN
    Grade = "S"
  ELSE
    Grade = "W"
  ENDIF
  DISPLAY Grade
END
StartINPUT MarksMarks >= 75?YesGrade = “A”NoMarks >= 65?YesGrade = “B”NoMarks >= 50?YesGrade = “C”NoMarks >= 35?YesGrade = “S”NoGrade = “W”DISPLAY GradeStop
Flowchart – Marks to grade (A, B, C, S, W)ගැලීම් සටහන – ලකුණු ශ්‍රේණියට (A, B, C, S, W)
💻 Marks to grade (A, B, C, S, W)ලකුණු ශ්‍රේණියට (A, B, C, S, W)
program MarksToGrade;
var
  marks: integer;
  grade: char;
begin
  write('Enter marks: ');
  readln(marks);
  if marks >= 75 then
    grade := 'A'
  else if marks >= 65 then
    grade := 'B'
  else if marks >= 50 then
    grade := 'C'
  else if marks >= 35 then
    grade := 'S'
  else
    grade := 'W';
  writeln('Grade: ', grade);
end.
marks = int(input("Enter marks: "))
if marks >= 75:
    grade = "A"
elif marks >= 65:
    grade = "B"
elif marks >= 50:
    grade = "C"
elif marks >= 35:
    grade = "S"
else:
    grade = "W"
print("Grade:", grade)

▶ Sample runනියැදි ධාවනය 1 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter marks: 82
Grade: A

▶ Sample runනියැදි ධාවනය 2 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter marks: 58
Grade: C

▶ Sample runනියැදි ධාවනය 3 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter marks: 30
Grade: W

4. Case (multi-way selection)4. Case (බහු-මාර්ග වරණය)

When one variable is compared with many fixed values (1, 2, 3…), Case is shorter and clearer than many IFs. Pascal uses case … of … else … end. Python (3.10 and later) uses match … case; case _ means “anything else”.එක් විචල්‍යයක් ස්ථාවර අගයන් (1, 2, 3…) බොහොමයක් සමඟ සසඳන විට, IF බොහොමයකට වඩා Case කෙටි සහ පැහැදිලිය. Pascal case … of … else … end භාවිත කරයි. Python (3.10 සහ පසු) match … case භාවිත කරයි; case _ යනු “වෙනත් ඕනෑම දෙයක්”.

📝 Pseudocodeව්‍යාජ කේතය (Pseudocode)

BEGIN
  INPUT Day
  CASE Day OF
    1 : DISPLAY "Sunday"
    2 : DISPLAY "Monday"
    3 : DISPLAY "Tuesday"
    4 : DISPLAY "Wednesday"
    5 : DISPLAY "Thursday"
    6 : DISPLAY "Friday"
    7 : DISPLAY "Saturday"
    OTHERWISE : DISPLAY "Invalid day"
  ENDCASE
END
StartINPUT DayDay = 1?YesDISPLAY “Sunday”NoDay = 2?YesDISPLAY “Monday”NoDay = 3?YesDISPLAY “Tuesday”NoDay = 4?YesDISPLAY “Wednesday”NoDay = 5?YesDISPLAY “Thursday”NoDay = 6?YesDISPLAY “Friday”NoDay = 7?YesDISPLAY “Saturday”NoDISPLAY “Invalid day”Stop
Flowchart – Case / switch: day number to day nameගැලීම් සටහන – Case / switch: දින අංකය දින නාමයට
💻 Case / switch: day number to day nameCase / switch: දින අංකය දින නාමයට
program DayName;
var
  day: integer;
begin
  write('Enter day number (1-7): ');
  readln(day);
  case day of
    1: writeln('Sunday');
    2: writeln('Monday');
    3: writeln('Tuesday');
    4: writeln('Wednesday');
    5: writeln('Thursday');
    6: writeln('Friday');
    7: writeln('Saturday');
  else
    writeln('Invalid day');
  end;
end.
day = int(input("Enter day number (1-7): "))
match day:
    case 1:
        print("Sunday")
    case 2:
        print("Monday")
    case 3:
        print("Tuesday")
    case 4:
        print("Wednesday")
    case 5:
        print("Thursday")
    case 6:
        print("Friday")
    case 7:
        print("Saturday")
    case _:
        print("Invalid day")

▶ Sample runනියැදි ධාවනය 1 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter day number (1-7): 3
Tuesday

▶ Sample runනියැදි ධාවනය 2 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter day number (1-7): 9
Invalid day

5. From flowchart to code – the steps5. ගැලීම් සටහනේ සිට කේතය දක්වා – පියවර

1
1. Read the diamondIts question becomes the IF condition.
1. දියමන්තිය කියවන්නඑහි ප්‍රශ්නය IF කොන්දේසිය වේ.
2
2. Yes branchWrite it after THEN.
2. ඔව් ශාඛාවTHEN ට පසුව ලියන්න.
3
3. No branchWrite it after ELSE (skip ELSE if empty).
3. නැත ශාඛාවELSE ට පසුව ලියන්න (හිස් නම් ELSE අවශ්‍ය නැත).
4
4. Where they joinWrite ENDIF (Pascal: end of statement; Python: stop indenting).
4. ඒවා එක් වන තැනENDIF ලියන්න (Pascal: ප්‍රකාශය අවසන්; Python: ඉන්ඩෙන්ට් කිරීම නවත්වන්න).
5
5. Test both pathsUse one input for Yes and one for No.
5. මාර්ග දෙකම පරීක්ෂා කරන්නඔව් සඳහා එක් ආදානයක් සහ නැත සඳහා එකක් භාවිත කරන්න.

Key Wordsප්‍රධාන පද

Selectionවරණය
Choosing which statements run using a condition.කොන්දේසියක් භාවිතයෙන් ක්‍රියාත්මක වන ප්‍රකාශ තේරීම.
If–EndIfIf–EndIf
Runs statements only when the condition is True.කොන්දේසිය සත්‍ය වූ විට පමණක් ප්‍රකාශ ක්‍රියාත්මක කරයි.
If–Else–EndIfIf–Else–EndIf
Chooses one of two groups of statements.ප්‍රකාශ කණ්ඩායම් දෙකකින් එකක් තෝරයි.
CaseCase
Chooses one of many options using fixed values.ස්ථාවර අගයන් භාවිතයෙන් විකල්ප බොහොමයකින් එකක් තෝරයි.
THENTHEN
Starts the part that runs when the condition is True.කොන්දේසිය සත්‍ය වූ විට ක්‍රියාත්මක වන කොටස ආරම්භ කරයි.
ELSEELSE
Starts the part that runs when the condition is False.කොන්දේසිය අසත්‍ය වූ විට ක්‍රියාත්මක වන කොටස ආරම්භ කරයි.
ENDIFENDIF
Marks the end of an IF in pseudocode.ව්‍යාජ කේතයේ IF එකක අවසානය සලකුණු කරයි.
match … casematch … case
Python’s case statement (Python 3.10+).Python හි case ප්‍රකාශය (Python 3.10+).
Indentationඉන්ඩෙන්ටේෂන්
Spaces at the start of a line; Python uses it to group statements.පේළියක මුල හිස්තැන්; Python ප්‍රකාශ කාණ්ඩ කිරීමට භාවිත කරයි.
Branchශාඛාව
One of the paths out of a decision.තීරණයකින් පිටවන මාර්ගවලින් එකක්.
Even numberඉරට්ටේ සංඛ්‍යාව
A number with N mod 2 = 0.N mod 2 = 0 වන සංඛ්‍යාවක්.
Test dataපරීක්ෂණ දත්ත
Inputs chosen to check every path of a program.වැඩසටහනක සෑම මාර්ගයක්ම පරීක්ෂා කිරීමට තෝරාගත් ආදාන.

Sample Q&Aආදර්ශ ප්‍රශ්න සහ පිළිතුරු

1What is the difference between If–EndIf and If–Else–EndIf?If–EndIf සහ If–Else–EndIf අතර වෙනස කුමක්ද?

Answerපිළිතුර: If–EndIf does something or nothing; If–Else–EndIf always does one of two things.If–EndIf යමක් කරයි හෝ කිසිවක් නොකරයි; If–Else–EndIf සැමවිටම දෙකින් එකක් කරයි.

2For a bill of Rs. 6500, what discount does the program give?රු. 6500 බිලක් සඳහා වැඩසටහන දෙන වට්ටම කීයද?

Answerපිළිතුර: Rs. 650; amount to pay Rs. 5850.රු. 650; ගෙවිය යුත්තේ රු. 5850.

3What grade does 58 get?58 ට ලැබෙන ශ්‍රේණිය කුමක්ද?

Answerපිළිතුර: C (≥ 50 but < 65).C (≥ 50 නමුත් < 65).

4When is Case better than many IFs?IF බොහොමයකට වඩා Case හොඳ වන්නේ කවදාද?

Answerපිළිතුර: When one variable is compared with many fixed values.එක් විචල්‍යයක් ස්ථාවර අගයන් බොහොමයක් සමඟ සසඳන විට.

5What does the day program display for 9?day වැඩසටහන 9 සඳහා පෙන්වන්නේ කුමක්ද?

Answerපිළිතුර: Invalid day.Invalid day.

6Why must we test both paths of an IF?IF එකක මාර්ග දෙකම පරීක්ෂා කළ යුත්තේ ඇයි?

Answerපිළිතුර: A mistake may be hidden in the path we did not test.අප පරීක්ෂා නොකළ මාර්ගයේ වැරැද්දක් සැඟවී තිබිය හැක.

MCQබහුවරණ ප්‍රශ්න

Choose the correct answer for each question.සෑම ප්‍රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.

Scoreලකුණු: 0 / 15

1In If–EndIf, when the condition is False…If–EndIf හි කොන්දේසිය අසත්‍ය වූ විට…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D

Skipped.මඟ හැරේ.

2If–Else–EndIf always runs…If–Else–EndIf සැමවිටම ධාවනය කරන්නේ…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

One of two.දෙකෙන් එකක්.

3Bill Rs. 6500 with 10% discount over Rs. 5000. Amount to pay is…රු. 5000 ට වැඩි නම් 10% වට්ටම සමඟ රු. 6500 බිල. ගෙවිය යුත්තේ…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

6500 − 650.6500 − 650.

4Bill Rs. 3000 in the same program. Discount is…එම වැඩසටහනේම රු. 3000 බිල. වට්ටම…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

Not over 5000.5000 ට වැඩි නැත.

5The even/odd program shows “7 is odd” because…even/odd වැඩසටහන “7 is odd” පෙන්වන්නේ…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

Remainder 1.ශේෂය 1.

6The O/L grade for 82 marks is…ලකුණු 82 සඳහා O/L ශ්‍රේණිය…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

≥ 75.≥ 75.

7The O/L grade for 30 marks is…ලකුණු 30 සඳහා O/L ශ්‍රේණිය…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

< 35.< 35.

8The O/L grade for 66 marks is…ලකුණු 66 සඳහා O/L ශ්‍රේණිය…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

65–74.65–74.

9Choosing a day name from a day number 1–7 is best done with…දින අංකය 1–7 න් දින නාමය තේරීමට වඩාත් සුදුසු…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

Many fixed values.ස්ථාවර අගයන් බොහොමයක්.

10Python’s case statement uses the words…Python හි case ප්‍රකාශය භාවිත කරන වචන…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

Python 3.10+.Python 3.10+.

11In Pascal, what must NOT come just before else?Pascal හි else ට කෙළින්ම පෙර නොතිබිය යුත්තේ කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D

Semicolon ends the if.Semicolon if අවසන් කරයි.

12Python groups the statements inside an if by…Python if එකක් තුළ ප්‍රකාශ කාණ්ඩ කරන්නේ…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

Indentation.ඉන්ඩෙන්ටේෂන්.

13In a flowchart, the Yes branch of a decision becomes the… part.ගැලීම් සටහනක තීරණයක ඔව් ශාඛාව වන්නේ … කොටසයි.

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

Yes → THEN.ඔව් → THEN.

14In Pascal case, the part for “any other value” is written…Pascal case හි “වෙනත් ඕනෑම අගයක්” සඳහා කොටස ලියන්නේ…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D

Pascal: else.Pascal: else.

15To test a pass/fail program fully, use…pass/fail වැඩසටහනක් සම්පූර්ණයෙන් පරීක්ෂා කිරීමට භාවිත කරන්න…

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

Test both paths.මාර්ග දෙකම පරීක්ෂා කරන්න.

MCQ answer keyMCQ පිළිතුරු

  1. D – Skipped.මඟ හැරේ.
  2. B – One of two.දෙකෙන් එකක්.
  3. C – 6500 − 650.6500 − 650.
  4. A – Not over 5000.5000 ට වැඩි නැත.
  5. B – Remainder 1.ශේෂය 1.
  6. C – ≥ 75.≥ 75.
  7. A – < 35.< 35.
  8. B – 65–74.65–74.
  9. A – Many fixed values.ස්ථාවර අගයන් බොහොමයක්.
  10. C – Python 3.10+.Python 3.10+.
  11. D – Semicolon ends the if.Semicolon if අවසන් කරයි.
  12. C – Indentation.ඉන්ඩෙන්ටේෂන්.
  13. B – Yes → THEN.ඔව් → THEN.
  14. D – Pascal: else.Pascal: else.
  15. A – Test both paths.මාර්ග දෙකම පරීක්ෂා කරන්න.

Structured Questionsව්‍යුහගත ප්‍රශ්න

1A shop gives a 10% discount when the bill is more than Rs. 5000. (i) Draw the flowchart. (ii) Write the pseudocode. (iii) Find the amount to pay for Rs. 6500 and Rs. 3000. (6 marks)බිල රු. 5000 ට වැඩි විට කඩයක් 10% වට්ටමක් දෙයි. (i) ගැලීම් සටහන අඳින්න. (ii) ව්‍යාජ කේතය ලියන්න. (iii) රු. 6500 සහ රු. 3000 සඳහා ගෙවිය යුතු මුදල සොයන්න. (ලකුණු 6) (6 marksලකුණු 6)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
(i) Start, input Total, Discount = 0, diamond Total > 5000?, Yes → Discount = Total × 10 / 100, display, Stop (2). (ii) As shown (2). (iii) Rs. 5850 and Rs. 3000 (2).(i) Start, Total ආදානය, Discount = 0, දියමන්තිය Total > 5000?, ඔව් → Discount = Total × 10 / 100, පෙන්වීම, Stop (2). (ii) පෙන්වා ඇති පරිදි (2). (iii) රු. 5850 සහ රු. 3000 (2).

📝 Pseudocodeව්‍යාජ කේතය (Pseudocode)

BEGIN
  INPUT Total
  Discount = 0
  IF Total > 5000 THEN
    Discount = Total * 10 / 100
  ENDIF
  DISPLAY Discount, Total - Discount
END
StartINPUT TotalDiscount = 0Total > 5000?Discount = Total * 10 / 100YesNoDISPLAY Discount, Total – DiscountStop
Flowchart – If–EndIf: 10% discount on a bill over Rs. 5000ගැලීම් සටහන – If–EndIf: Rs. 5000 ට වැඩි බිලකට 10% වට්ටම

2Write a program (Pascal or Python) to input a number and display whether it is even or odd. (4 marks)සංඛ්‍යාවක් ආදානය කර එය ඉරට්ටේද ඔත්තේද යන්න පෙන්වන වැඩසටහනක් (Pascal හෝ Python) ලියන්න. (ලකුණු 4) (4 marksලකුණු 4)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
Input (1); condition N mod 2 = 0 (1); display even (1); else display odd (1).ආදානය (1); කොන්දේසිය N mod 2 = 0 (1); ඉරට්ටේ පෙන්වීම (1); නැතිනම් ඔත්තේ පෙන්වීම (1).
💻 If–Else–EndIf: even or oddIf–Else–EndIf: ඉරට්ටේ හෝ ඔත්තේ
program EvenOdd;
var
  n: integer;
begin
  write('Enter a number: ');
  readln(n);
  if n mod 2 = 0 then
    writeln(n, ' is even')
  else
    writeln(n, ' is odd');
end.
n = int(input("Enter a number: "))
if n % 2 == 0:
    print(n, "is even")
else:
    print(n, "is odd")

▶ Sample runනියැදි ධාවනය 1 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter a number: 14
14 is even

▶ Sample runනියැදි ධාවනය 2 · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter a number: 7
7 is odd

3Write pseudocode that inputs marks and displays the O/L grade (A ≥ 75, B ≥ 65, C ≥ 50, S ≥ 35, W otherwise). (5 marks)ලකුණු ආදානය කර O/L ශ්‍රේණිය පෙන්වන ව්‍යාජ කේතය ලියන්න (A ≥ 75, B ≥ 65, C ≥ 50, S ≥ 35, නැතිනම් W). (ලකුණු 5) (5 marksලකුණු 5)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
Input (1); IF ≥ 75 A (1); ELSE IF ≥ 65 B, ≥ 50 C (1); ≥ 35 S (1); ELSE W and display (1).ආදානය (1); IF ≥ 75 A (1); ELSE IF ≥ 65 B, ≥ 50 C (1); ≥ 35 S (1); ELSE W සහ පෙන්වීම (1).

📝 Pseudocodeව්‍යාජ කේතය (Pseudocode)

BEGIN
  INPUT Marks
  IF Marks >= 75 THEN
    Grade = "A"
  ELSE IF Marks >= 65 THEN
    Grade = "B"
  ELSE IF Marks >= 50 THEN
    Grade = "C"
  ELSE IF Marks >= 35 THEN
    Grade = "S"
  ELSE
    Grade = "W"
  ENDIF
  DISPLAY Grade
END

4(i) When is a Case statement used? (1 mark)
(ii) Write a Case statement in pseudocode that displays “Sunday” for 1, “Monday” for 2 and “Invalid day” otherwise. (3 marks)
(i) Case ප්‍රකාශයක් භාවිත කරන්නේ කවදාද? (ලකුණු 1)
(ii) 1 සඳහා “Sunday”, 2 සඳහා “Monday” සහ නැතිනම් “Invalid day” පෙන්වන Case ප්‍රකාශයක් ව්‍යාජ කේතයෙන් ලියන්න. (ලකුණු 3)
(4 marksලකුණු 4)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
(i) When one variable is compared with many fixed values. (ii) CASE Day OF 1 : DISPLAY “Sunday”; 2 : DISPLAY “Monday”; OTHERWISE : DISPLAY “Invalid day”; ENDCASE.(i) එක් විචල්‍යයක් ස්ථාවර අගයන් බොහොමයක් සමඟ සසඳන විට. (ii) CASE Day OF 1 : DISPLAY “Sunday”; 2 : DISPLAY “Monday”; OTHERWISE : DISPLAY “Invalid day”; ENDCASE.

5Find the error in this Pascal code and correct it: if Mark >= 35 then writeln(‘Pass’); else writeln(‘Fail’); (2 marks)මෙම Pascal කේතයේ දෝෂය සොයා නිවැරදි කරන්න: if Mark >= 35 then writeln(‘Pass’); else writeln(‘Fail’); (ලකුණු 2) (2 marksලකුණු 2)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
There must be no semicolon before else (1). Correct: if Mark >= 35 then writeln(‘Pass’) else writeln(‘Fail’); (1).else ට පෙර semicolon නොතිබිය යුතුය (1). නිවැරදි: if Mark >= 35 then writeln(‘Pass’) else writeln(‘Fail’); (1).

🎮 Game🎮 ක්‍රීඩා

Pick a game. Each one uses words from this lesson.ක්‍රීඩාවක් තෝරන්න. හැම එකක්ම මේ පාඩමේ වචන පාවිච්චි කරනවා.

Summary & Downloadsසාරාංශය සහ බාගත කිරීම්

Key pointsප්‍රධාන කරුණු

  • Selection = making a decision.වරණය = තීරණයක් ගැනීම.
  • If–EndIf: do it or skip it.If–EndIf: කරන්න හෝ මඟ හරින්න.
  • If–Else–EndIf: one of two paths.If–Else–EndIf: මාර්ග දෙකෙන් එකක්.
  • ELSE IF chains check conditions in order.ELSE IF දාම කොන්දේසි පිළිවෙළින් පරීක්ෂා කරයි.
  • Case: one of many fixed values.Case: ස්ථාවර අගයන් බොහොමයකින් එකක්.
  • Pascal: case … of; Python: match … case.Pascal: case … of; Python: match … case.
  • Pascal: no ; before else. Python: indent.Pascal: else ට පෙර ; නැත. Python: ඉන්ඩෙන්ට්.
  • Test every path with test data.පරීක්ෂණ දත්ත මගින් සෑම මාර්ගයක්ම පරීක්ෂා කරන්න.

Downloadsබාගත කිරීම්

Full Lesson 1 PDFසම්පූර්ණ පාඩම 1 PDF: English · සිංහල

Next noteඊළඟ සටහන 1.7 →

© 2026 schoolict.net (Ruwan Mangala Suraweera). All rights reserved.සියලු හිමිකම් ඇවිරිණි.