Algorithm and Flow charts
When we want to solve a problem, we have to carefully understand and analyze
the problem first. Then we need to find inputs required to produce the expected output.
In between the input and output there are processes and storing mechanisms.
An algorithm is a systematic and carefully organized series of steps to solve a
problem. A flow chart is a symbolic method of representing an algorithm.
Ex: Lets think a doctor wants to give some information about corona pandemic related
to past week. He needs to produce a report stating total number of patients and deaths
for the given week and average deaths and patients per day for the given time period.
Date Reported Number of patients Reported number of
deaths
1-10-2020 988 2
2-10-2020 1023 4
3-10-2020 1434 2
4-10-2020 1123 4
5-10-2020 789 0
6-10-2020 766 1
7-10-2020 997 2
Total number of patients 7120
Total number of deaths 15
Number of patients per 7120/7 = 1017
day
Number of deaths per day 15/7 = 2
Symbols in Flow Charts
Start/End Process Input/Output
Decision Connector Data Flow
Homework (Thursday) – Write an algorithm to find the area of a circle and
circumference of the same circle. Finally display the area and circumference.
Area of a circle is calculated based on the following equation.
Value of PI is = 22/7
If radius is 7cm
Areas is = 22/7 x 7cm x 7cm
= 22 x 7 cm2
= 154 cm2
Algorithm
Step 01: Find/Input the radius
Step 02: Calculate the area
Step 03: Display the area
Circumference of a circle = 2 x PI x r
Value of PI is = 22/7
Circumference = 2 x 22/7 x 7cm
= 44cm
Algorithm
Step 01: Find/Input the radius
Step 02: Calculate the circumference
Step 03: Display the circumference
Area of a rectangle
Inputs: Length, Width of the rectangle
Process: Area = Length x Width
Output: Area of the rectangle
Algorithm
Step 01: Input Length and Width
Step 02: Area = Length x Width
Step 03: Display Area
Circumference of a rectangle
Inputs: Length, Width of the rectangle
Process: Circumference = (Length + Width) x 2
Output: Circumference of the rectangle
Algorithm
Step 01: Input Length, Width
Step 02: Circumference = (Length + Width) x 2
Step 03: Circumference of the rectangle
Start Start
Input Length Input Length
Input Width Input Width
Area = Width x Length Circumference = (Length+ Width) x 2
Display Area Display Circumference
End End
Q. Draw a flow chart to input 2 numbers, find the total and output the total.
Start
Input Number 1
Input Number 2
Total = Number 1 + Number 2
Display Total
End
Show steps of preparing tea and serving it using a flow chart
Start
Input Tea, Sugar, Water, Milk
Boil Water
Mix Tea
Filter Tea after 3 mins
Add sugar and milk
Mix all
Serve the Tea
End
Control Structures
When we write algorithm to solve problems there are 3 common program flows to
follow, which are called control structures.
1. Sequence – In sequence, instructions will be executed one after another
according to a sequential order.
This is similar to how you came from grade 1 to grade 6; 1 grade at a time.
2. Selection – In this control structure, we have to select a program flow or
instruction flow based on a condition.
As an example, consider 2 simultaneous classes. You can participate only to
a selected class based on your requirement.
3. Repetition - In this control structure, same instructions are executed again
and again based on a condition. As an example, you have to come to the
classes again and again until the syllabus is over.
Q. Draw a flow chart to insert 2 integer numbers and print/display the
minimum (smallest) number
Start
Input Number 1
Input Number 2
Number 1 > Number 2
yes
no
Display Number 1
Display Number 2
End
Draw a flow chart to enter marks of 3 subjects (Maths, English and IT). If all marks are
greater than 50, then display as ‘Pass’. If not display as ‘Fail’
Start
Input MathsMarks,
English Marks, ITMarks
If MathsMarks>50 AND
EnglishMarks > 50 AND
ITMarks > 50
yes
no
Display ‘Fail’
Display ‘Pass’
End
ඇල්ෙගාරිතම සහ ගැලීම් සටහන්
ෛවද$වරෙයකුට පසුගිය සතිය සම්බන්ධ ෙකාෙරෝනා ෙරෝගීන් සහ මරණ ගැන වාර්තාවක් ලබාදීමට සිදුවී
ඇත. ඒ සදහා ඔහු මුලින් සතිෙය් දින හෙත් අදාල අගයක් වගුවක පහත පරිදි ඇතුලත් කර ගනී. ෙමය පරිගණකයක නම්
ආදානයකට සමාන ෙව්. ෙමෙස් ආදානය වන දත්ත මතකෙය් තැම්පත් ෙකෙර්. දිගු කාලීන බාවිතය සදහා ආචනෙය්ද
තැම්පත් ෙකෙර්.
ෙමම වගුෙව් දත්ත අනුව, එකතුව ලබා ගැනීෙම පසුගිය සතිෙය් වාර්තා වූ මුළු මරණ ගණන සහ මුළු ෙරෝගීන්
ගණන ගණනය කිරීෙම් කියාවලිය කළ හැකිය. ඉන් අනතුරුව දින 7න් ඉහත අගයන් ෙබදා, ෛදනිකව වාර්තා වන
සාමාන$ අගයන් පකාශ කළ හැකිය. ෙමහිදී සැකසීම සහ පතිදානය සිදුෙව්.
දිනය වාර්තා වූ ෙකාෙරෝනා ආසාධිතයින් වාර්තා වූ ෙකාෙරෝනා මරණ
1-10-2020 988 2
2-10-2020 1023 4
3-10-2020 1434 2
4-10-2020 1123 4
5-10-2020 789 0
6-10-2020 766 1
7-10-2020 997 2
සාමාන$ෙයන් දිනකට 7120/7 = 1017
වාර්තාවන ෙරෝගීන් ගණන?
සාමාන$ෙයන් දිනකට 2
වාර්තාවන ෙකාෙරෝනා මරණ
ගණන?
පසුගිය සතිෙය් ෙකාෙරෝනා 15
මරණ ගණන
පසුගිය සතිෙය් ෙකාෙරෝනා 7120
ෙරෝගීන් ගණන
ෙමෙස් යම් ගැටළුවක් විසදීමට ෙයාදා ගන්නා සැලසුම් සහගත කමාණුකුල කමෙව්දය ඇල්ෙගාරිතමයක් ෙලස
හැදින්ෙව්. එය රූපමය ආකාරෙයන් විෙශ්ෂිත සංෙක්ත බාවිතා කර ෙපන්වන රූප සටහන් ගැලීම් සටහන් ෙලස
හැදින්ෙව්.
ගැලීම් සටහන් වල බාවිතා වන සංෙක්ත
ආරම්භය/අවසානය කියාවලි
ආදාන/පතිදාන තීරණ
දත්ත ගැලීම සම්බන්ධක
Q. සංඛMා 2ක් ආදාන ෙලස ලබාෙගන ඒවා එකතුකර පතිදානයක් ෙලස එකතුව ලබාදීමට ගැලීම් සටහනක්
ෙයෝජනා කරන්න.
පරිගණකය මගින් යම්කිසි කාර්යයක් සිදුකරවා ගැනීෙම්දී ඊට අදාල උපෙදස් අඩංගු
වැඩසටහන් බාවිතා වන බව අපි ඉෙගන ගත්ෙතමු. එම උපෙදස් ලබාදී වැඩසටහන් සාදා
ගැනීමට කමෙල්ඛ ෙයාදාගැෙන්. ෙමහිදී කමෙල්ඛ ලිවීමට අපි scratch බාවිතා කරන අයුරු
ඉෙගන ගනිමු.
ගැටළුව සරල නම් අපිට පහසුෙවන් විසදීමට හැකි අතර, ගැටළුව සංකීර්ණ විට එය
කුඩා ෙකාටස් වලට විෙයෝජනය මගින් විශ්ෙල්ෂණය, වටහා ගැනීම, විස්තර කිරීම සහ
විසදීම පහසු කරගැනීමට හැකි ෙව්.
ගැටළුවක් විසිදීමට කමෙල්ඛ ලිවීෙම්දී පධාන පාලන වaහ 3ක් පහසුෙවන් හදුනාගත හැකිය.
1. අනුකමය/අනුපිළිෙවල (sequence)- උපෙදස් එකකට පසුව එකක් පිළිෙවලින්
කියාත්මක කිරීම
2. වරණය/ෙත්රීම (selection)- යම් තත්වයක් අනුව ලබාගන්නා තීරණයක් මත,
විකල්ප දිශා කීපයකින් එක් දිශාවක් ෙතෝරාෙගන එම දිශාෙව් ඇති උපෙදස්
පමණක් කියාත්මක කිරීම (දිශා = විවිධ උපෙදස් මාලා ඇති
මාර්ගයන්)
3. පුණර්කරණය (repetition) - යම් තත්වයක් අනුව ලබාගන්නා තීරණයක් මත,
එකම උපෙදස් මාලාව නැවත නැවත කියාත්මක කිරීම
සංඛ4ා ෙදකකින් වඩා විශාල සංඛ4ාව ෙපන්වීම ෙත්රීමකි/වරණයකි
ආරම්භය
පළමු සංඛ4ාව ඇතුලත් කිරීම
ෙදවන සංඛ4ාව ඇතුලත් කිරීම
පළමු සංඛ4ාව > නැත
ෙදවන සංඛ4ාව
ෙදවන සංඛ4ාව ෙපන්වන්න
ඔව්
පළමු සංඛ4ාව ෙපන්වන්න
අවසානය
ආරම්භය
සෘජුෙකෝණාශෙය් දිග ලබා ගැනීම
සෘජුෙකෝණාශෙය් පළල ලබා ගැනීම
පරිමිතිය = (දිග + පළල) x 2
සෘජුෙකෝණාශෙය් පරිමිතිය ෙපන්වීම
අවසානය
Start
Input Height of the Rectangle
Input Width of the Rectangle
Start
Take water, tea leaves, sugar and milk powder
Boil Water
Add tea leaves to boil water
Mix milk powder and sugar
Add plain tea to the above mixture
Prepare the cup of tea mixing all
Serve the tea
Stop
Finding Perimeter of Rectangle
ෙතාරතුරු රැස් කිරීම සහ සන්නිෙව්දනය සදහා අන්තර් ජාලය බාවිතය
Using Internet for collecting information and communication
Internet is an Infrastructure for a lot of services. It is a network of
networks. A network is 2 or more computers, connected though wired
or wireless media, for the purpose of resource sharing and
communication. A lot of such networks, and independent computers
and devices are inter-connecting and communicating though Internet.
Word Wide Web, Email, Instant Messengers, Remote access, File
sharing, Teleconferencing, are some of the most popular services in the
Internet.
Internet connects both people and devices (Internet of things).
Information added to the Internet withing a single day by these things
and people, cannot be referenced and accessed even within the life
time of average person.
Internet is owned by general public.
අන්තර් ජාලය යනු ෙස්වා රැසක් සදහා පහසුකම් සැපෙයන, ෙලෝකය පුරාම
විහිදී ඇති, මහ ජනතාවට අයිති, ෙපාදු, යටිතල පහසුකමකි. ෙවබ් පිටු සහ
අඩවි, විදPත් තැපැල්, දුරස්ථ පිවිසීම, වීවිෙයෝ සම්මන්තණ, ෙගානු හුවමාරුව
ආදිය මින් ලැෙබන ෙස්වා අතර පධාන ෙව්.
අන්තර් ජාලයට මිනිසුන් පමණක් ෙනාව උපාංගද සම්බන්ධ වී පවතී. එම
උපාංග මගින් සහ මිනිසුන් විසින් එක් දිනකදී එකතු කරන දත්ත සහ
ෙතාරතුරු, සාමානe මිනිෙසකුට තම ජීවිත කාලය පුරාම පවා පරිශීලනය කර
අවසාන කළ ෙනාහැක.
පරිගණක ජාලයක් යනු එකිෙනකට සම්බන්ධ වූ පරිගණක සහ පරිගණක
උපාංග රැසක එකතුවකි. එය සන්නිෙව්දනය සහ සම්පත් ෙපාදු පරිහරණය ෙහෝ
ෙබදා ගැනීම සදහා ෙයාදා ගැෙන්.
අන්තර්ජාලය ෙමෙස් සෑදුනු ජාල සහ පරිගනක රැසක් එකිෙනකට සම්බන්ධ
කරමින් ෙලෝකය පුරා විහිදුනු ජාලයන්ෙග් ජාලයක් ෙලස පවතී.
අන්තර්ජාලයට සම්බන්ධ වන ආකාරය
How do we connect to the Internet?
1. අන්තර්ජාල සම්බන්ධ තාවයක් - අන්තර්ජාල ෙස්වා සැපයුම්කරුවන් (ISP –
Internet Service Provider) විසින් ලබාෙද්
A valid connection from an Internet Service Provider (ISP)
SLT, Dialog, Mobitel, Airtel, Hutch (wired or wireless connection)
2. අන්තර්ජාලයට පිවිසිය හැකි උපාංගයක්
A device which support to connect Internet
උදා: ලැප්ෙටාප්, ෙඩස්ක්ෙටාප් පරිගණක, ජංගම දුරකථන, ටැබ්, IP කැමරා, සුහුරු
උපාංග (ශීතකරණ, TV)
Ex: Laptop, Desktop. Mobile Phone, Tab, IP Camera, Smart Devices
(Watches, Refrigeration, TV)
3. අන්තර්ජාල ෙස්වාවලට අදාල වූ මෘදුකාංගයක්
A service-specific software program
ෙවබ් - ෙවබ් අතිරික්සු
Web- Web browser (Google chrome, Firefox, Opera, Safari, Internet
explorer, Edge, tor)
ක්ෂණික පණිවිඩ
Instant messengers - whatsapp, viber, imo, telegram, messenger
සමාජ ජාල
Social Networking - facebook, instagram, youtube
Teleconferencing – Zoom, MS Team, Skype
Service related programs
කාර්ය බද්ධ ඇප්ස් - අදාල කාර්යය අනුව සැකසූ
Web site – is a collection of inter-related web pages under single name
Ex: all pages under google.com
Web page – is a collection or related text, and multimedia such as audio,
video and images as a single document
Web browser – is a special software used to access web sites and pages
(Google chrome, Firefox, Opera, Safari, Internet explorer, Edge, tor)
Search engine – is a special web page which is used to search other web
pages
Ex: www.google.com , www.duckduckgo.com, www.bing.com ,
www.answers.com, www.ask.com,
How to access a website using web browser
Type the full address or partial address in the address bar of the
web browser and press enter
http://www.google.com - full
www.google.com – partial
Method2:
Search the web site using search engine such as
www.google.com, www.duckduckgo.com, www.bing.com
And then click on the link
ෙසවුම් යන්ත - අෙනකුත් ෙවබ් පිටු ෙසවීම සදහා ෙයාදා ගන්නා විෙශ්ෂ
ෙවබ් අඩවි ෙසවුම් යන්ත ෙව්.
උදා: www.google.com, www.duckduckgo.com, www.bing.com
www.google.com ෙසවුම් යන්තය මගින් නිවැරදිව යම් ෙගානුවක් එය
ඇති ෙවබ් අඩවිය ලබාදීෙමන් ෙහෝ ෙපාදුෙව් ෙසායා ගැනීම
සීගිරිය|sigiriya filetype:ppt site:lk
ෙමමගින් සීගිරිය ගැන සමර්පණ / powerpoint ෙගානු පමණක් ෙසායා
ගත හැකිය. එෙමන්ම ඒවා .lk (ලංකාෙව් ලියාපදිංචි) අඩවි වල පමණක්
ෙසායයි.
ඔෙබ් පරිගණකෙය් ස්ථාපනය කළ හැකි ෙවබ් අතරික්සු (web browser)
1. Internet Explorer – Microsoft ආයතනය විසින් ෙනාමිෙල් ලබා දුනි. එෙහත් නව ෙමෙහයුම්
පද්ධති සමග Microsoft Edge අතරික්සුව ෙම් ෙවනුවට ලබා ෙද්.
2. Mozilla Firefox - ෙනාමිෙල් ලැෙබන විවෘත ෙක්ත මෘදුකාංගයකි
3. Google Chrome- ෙනාමිෙල් ලැෙබන විවෘත ෙක්ත මෘදුකාංගයකි
4. Opera- ෙනාමිෙල් ලැෙබන විවෘත ෙක්ත මෘදුකාංගයකි. අඩු මතක ධාරිතාවයක් ෙයාදා ගැෙන්
5. Chromium - ෙනාමිෙල් ලැෙබන විවෘත ෙක්ත මෘදුකාංගයකි. අඩු මතක ධාරිතාවයක් ෙයාදා
ගැෙන්. (විෙශ්ෂෙයන් තනි පුවරු පරිගණක වල)
6. Tor - අදුරු ෙවබ් අඩවි වලට රහසිගතව පිවිසීම සදහා බාවිතා ෙව්
7. Safari – Apple සමාගෙමන් සදුන්වා දී ඇත
Different web browsers and usages
1. Internet Explorer – It was given with Microsoft windows for free. Not much popular
due to less user friendliness
2. Microsoft Edge – Internet explorer will be stopped and Edge was introduced by
Microsoft to replace it.
3. Mozilla Firefox – free and open-source web browser application
4. Google chrome - free and open-source web browser application
5. Opera - free and open-source web browser application which uses less memory and
light weight
6. Opera GX – special version of opera uses for games
7. Chromium – light weight (uses less memory) browser mostly used by low
performance processers such as raspberry PI single board computers
8. Safari – Introduced by Apple but can be used in other platforms too
9. Tor – Used to access web services anonymously. Some people use this for darknet
and deepweb