UNIT 6
FUNDAMENTALS OF
PROGRAMING
For Grade 10
Year: 2017
UNIT OUTCOMES
➢ At the end of this unit, learners will be able to:
➢Explain concepts of algorithms.
➢Describe the representation of algorithms.
➢Discuss Integrated Development Environment (IDE)
Unit Overview
➢ Problem-solving steps are used to solve day-to-day problems and make strategies
to handle different situations which keep arising in day-to-day life.
➢ One method of solving problems in computer science is using algorithms.
Basics of Algorithm
➢ Algorithm is a step-by-step process of solving a well-defined computational
problem.
➢ To solve problem:
➢First, define the problem and
➢Then design an algorithm.
➢ Algorithms are used to simplify the program implementation.
Cont…
➢ In computers, programs are developed to solve some problems.
➢ Steps to solve the problem using computers:
✓ The problem must be analyzed thoroughly
✓ Solution method is broken down into a sequence of small tasks
✓ Based on this analysis, an algorithm must be prepared to solve the problem
✓ The algorithm must be expressed in precise notation
Cont…
✓ In viewing algorithm, a computer program has to be designed in any high-
level language.
✓ The computer program is fed into the computer.
✓ The instruction in the program executes one after another and outputs the
expected result.
➢ Example: calculate the sum of two numbers
Activity
Answer the following activities accordingly.
1. Write the steps you may follow to do an everyday activity. It could be riding a
bike, making or cooking “Shiro wot”.
i. Discuss the steps you have written with your friend.
Definition of Algorithm
➢ An algorithm is a set of rules/instructions that define step-by-step how a work is
to be executed to get the expected results.
➢ An algorithm is a precise method of solving a problem.
➢ It consists of a sequence of unambiguous, step-by-step instructions.
➢ A program is an algorithm that has been converted into program code.
➢ An algorithm should be well-written.
➢ An algorithm is described in terms of input, process and output activities.
➢ An algorithm is a finite step-by-step procedure to achieve a required result.
Characteristics of Algorithm
Algorithm must have the following characteristics:
➢ Clear and unambiguous
➢ Well-defined inputs
➢ Well-defined outputs
➢ Finiteness
➢ Feasible
➢ Language independent
Advantages and Disadvantage of algorithm
Advantage
➢ It is easy to understand.
➢ It is a stepwise representation of a solution to a given problem.
➢ In the algorithm the problem is broken down into smaller pieces or steps;
hence, it is easier for the programmer to convert it into an actual program.
Disadvantages
➢ Writing an algorithm takes a long time, so it is time-consuming.
➢ Branching and looping statements are difficult to show in algorithms.
Examples of algorithm
Example 1: Algorithm for the sum of two numbers
➢ Step 1: Take the first number from the user (input).
➢ Step 2: Take the second number from the user (input).
➢ Step 3: Add the two numbers to get the sum (process).
➢ Step 4: Display the sum on the screen (output).
Classwork
1) Write an algorithm to check whether the entered
number is positive, negative or zero.
2) Calculate the sum of ten natural numbers.
Algorithm Representation
➢ There are two main ways in which algorithms can be represented; they are
a) Flowcharts Method: It’s a tool used to designing an algorithm.
✓ It is a graphical or schematic representation of the major steps of work in a process.
✓ It is a visual picture that gives steps of an algorithm
✓ It displays the essential steps of the program in separate boxes.
✓ It also shows the directions of information flow using arrows.
Basic Flowchart Symbols
➢ Example 1:
➢ Example 2: Draw a flow chart of an algorithm to add two numbers and display
their result.
➢ Solution:
➢ First prepare algorithm
➢ Based on the prepared algorithm, draw flow chart using symbols
➢ Algorithm description of Example 2:
a. Read the rules of the two numbers (A and B).
b. Add A and B.
c. Assign the sum of A and B to C.
d. Display the result (C).
➢ Flow chart design
for above algorithm:
Classwork
➢ Example 3: Draw a flowchart to check if a given number is positive or negative.
➢ Conditions, execute a group of statements repeatedly until some condition is
satisfied.
➢ This condition is called a loop.
➢ Loop is a sequence of instructions that is repeated until some specific condition
occurs.
➢ A loop normally consists of four parts. These are:
➢ Initialization
➢ Computation
➢ Test
➢ Increment
Homework
➢ Example 3: Write the algorithmic description and draw a flowchart to find the
sum of the first 20 natural numbers as stated: Sum = 1+2+3+…. + 20
Pseudocode
➢ It is a program design aid that serves the function of a flowchart in expressing the
detailed logic of a program.
➢ It uses English language statements to express algorithms.
➢ These statements can be used both as a guide and documentation.
➢ Because, there is no rigid rule for constructing pseudocodes.
➢ Example 1: Write the pseudocode to find the sum of two numbers.
Integrated Development Environment(IDE)
➢ Software is a large component of our lives these days.
➢ Computers need software to run.
➢ An IDE enables programmers to consolidate different aspects of writing a
computer program.
➢ IDEs used to edit source code, building executable, and debugging.
Definition of an IDE
➢ It is an application that facilitates application development.
➢ It is designed to encompass all programming tasks in one application.
➢ It offer a central interface featuring all the tools a software developer needs.
Common Features of Integrated Development
Environments
➢ The fundamental features of IDE are:
a) Code editor: designed for writing and editing source code.
✓ Example: VScode, Sublime, Bracket, Atom, …..
✓ What is the d/f b/n source code editors and text editors?
b) Text editors: designed to write and manipulate source code.
✓ Example: Notepad++, Sublime text, Vim, gedit, …..
c) Debugger : used during testing to help debug application programs
d) Build automation tools : automate common developer tasks. And also,
includes:
✓ Class browser
✓ Object browser
b) Class hierarchy diagram: allows the programmer to visualize the structure
of object-oriented programming code.
Benefits of Using IDEs
➢ It used to improved developer productivity by reducing setup time, increasing the
speed of development tasks, keeping developers up to date and standardizing the
development process.
a) Faster setup
b) Faster development tasks
c) IDEs streamline development by encouraging holistic thinking.
d) Continual learning
e) Standardization.
Different Types of IDE
➢ Some IDEs are designed to work with:
✓ One specific language
✓ Cloud-based IDEs
✓ IDEs customized for the development of mobile applications or HTML and
✓ IDEs meant specifically for Apple development or Microsoft development
➢ Some IDEs are designed to work with:
✓ One specific language
✓ Cloud-based IDEs
✓ IDEs customized for the development of mobile applications or HTML and
✓ IDEs meant specifically for Apple development or Microsoft development
➢ Multi-language IDE: Multi-language IDEs such as:
➢ Eclipse: Supports C++, Python, PHP, Java and more. This option is also free
and open source.
➢ NetBeans: Supports Java, JavaScript, PHP, Python, Ruby, C, C++ and more.
This option is also free and open source.
➢ Komodo
➢ IDE for a specific application:
✓ IDE for mobile development: example, Android Studio and Visual Studio
✓ HTML IDE: example, HomeSite, DreamWeaver or FrontPage.
✓ Cloud-based IDE: example, Nitrous - supports more than 40 languages
including PHP, Ruby, Python, JavaScript with Node.js and Go.
End!