0% found this document useful (0 votes)
59 views11 pages

Unit 6

Abcde and a

Uploaded by

tmengistutk1970
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views11 pages

Unit 6

Abcde and a

Uploaded by

tmengistutk1970
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIT 6

FUNDAMENTALS OF PROGRAMING

Definition of Algorithm

Algorithm is a step-by-step process of solving a well-defined computational


problem.

Some of the most widely used definitions of an algorithm are described here under.
ƒ

 An algorithm is a set of rules for carrying out calculations either by hand or


a machine. ƒ
 An algorithm is a finite step-by-step procedure to achieve a required result.
ƒ
 An algorithm is a sequence of computational steps that transform the input
into the output.

To solve the problem using computers, we must follow the steps described below.

a. The problem must be analyzed thoroughly.


b. Solution method is broken down into a sequence of small tasks.
c. Based on this analysis, an algorithm must be prepared to solve the problem.
d. The algorithm must be expressed in precise notation.
e. In viewing algorithm, a computer program has to be designed in any high-
level language.
f. The computer program is fed into the computer.
g. The instruction in the program executes one after another and outputs the
expected result.

Characterstics of Algorithm

1
 Clear and unambiguous: The algorithm should be unambiguous. Each of
its steps should be clear in all aspects and must lead to only one meaning.
 Well-defined inputs: If an algorithm says to take inputs, they should be
well-defined.
 Well-defined outputs: The algorithm must clearly define what output will
be yielded and it should be well-defined as well.
 Finiteness: The algorithm must be finite, i.e. it should not end up in infinite
loops or similar.
 Feasible: The algorithm must be simple, generic and practical so that it can
be executed upon the available resources. It must not contain some future
technology or anything.
 Language independent: The algorithm designed must be language
independent, i.e. it must be just plain instructions that can be implemented in
any language, and yet the output will be the same as expected.

Advantages of algorithm ƒ

 It is easy to understand. ƒ Algorithm is a stepwise representation of a


solution to a given problem.

2
 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 of algorithm

 ƒ writing an algorithm takes a long time, so it is time-consuming.


 Branching and looping statements are difficult to show in algorithms.

Example: Write an algorithm to check whether the entered number is positive,


negative or zero.

ƒ Step 1: Take the number from the user.

ƒ Step 2: If the number is less than 0, then display that the entered number is
negative.

ƒ Step 3: If the number is greater than 0, display that the entered number is
positive.

ƒ Step 4: Otherwise, display that the entered number is zero.

6.5 Algorithm Representation

3
We need a way to describe our algorithms in a precise manner with a well-defined
syntax and clear, unambiguous semantics.

There are two main ways in which algorithms can be represented; they are
flowcharts and pseudo code.

6.5.1 Flowchart Method

An algorithm can be described using many techniques and tools. One tool for
designing an algorithm is by using a flowchart.

A flowchart is a graphical or schematic representation of the major steps of work


in a process. It displays the essential steps of the program in separate boxes and
shows the directions of information flow using arrows.

A flow chart for the program of displaying the sum of two numbers

4
Example 3: Write the algorithmic description and draw a flowchart to find
the sum of the first 50 natural numbers as stated: Sum = 1+2+3+…. + 50

Algorithmic description

1. Initialize sum to zero (0) and counter to 1.

1.1 If the counter is less than or equal to 50,

ƒ Add counter to sum.

ƒ Increase counter by 1.

ƒ Repeat the above steps.

1.2 Else Exit

2. Write the sum

5
6.5.2 Pseudocode

Pseudocode is a program design aid that serves the function of a flowchart in


expressing the detailed logic of a program. Sometimes a program’s flowchart
might be inadequate for expressing the control flow and logic of the program.
Using pseudocode, the program’s algorithm can be expressed as English language
statements. These statements can be used both as a guide when coding the program
in a specific language and as documentation for review by others.

6
6.6 Integrated Development Environment (IDE)

An IDE enables programmers to consolidate different aspects of writing a


computer program. IDEs increase programmer productivity by combining common
activities of writing software into a single application: editing source code,
building executable, and debugging.

An integrated development environment (IDE) is an application that facilitates application


development. IDEs are designed to encompass all programming tasks in one application.
Therefore, IDEs offer a central interface featuring all the tools a software developer needs,
including the following functionalities as shown in Figure below

7
Common Features of Integrated Development Environments

An IDE typically contains a code editor, a compiler or interpreter, and a debugger accessed
through a single graphical user interface (GUI). The user writes and edits source code in the code
editor. The compiler translates the source code into a readable language that is executable for a
computer. The debugger tests the software to solve any issues or bugs. The fundamental features
of IDE are discussed in the following. ƒ

 Code editor: This feature is a text editor designed for writing and editing source code.
Source code editors are distinguished from text editors because they enhance or simplify
the writing and editing of code.

 Text editors: Virtually every IDE will have a text editor designed to write and
manipulate source code. ƒ

8

 Debugger: This tool is used during testing to help debug application programs. ƒ
 Build automation tools: These tools automate common developer tasks. In addition,
some IDEs might also include the following:
 Class browser: This tool is used to examine and reference the properties
of an object-oriented class hierarchy.
 Object browser: This feature is used to examine the objects instantiated
in a running application program. ƒ
 Class hierarchy diagram: This tool allows the programmer to visualize the structure of
object-oriented programming code. Note that IDE may be a stand-alone application or
may be included as part of one or more compatible applications.

6.6.2 Benefits of Using IDEs

The overall goal and main benefit of an integrated development environment are improved
developer productivity. IDEs boost productivity by reducing setup time, increasing the speed of
development tasks, keeping developers up to date and standardizing the development process.

 Faster setup: Without an IDE interface, developers would need to spend time
configuring multiple development tools. With the application integration of an IDE,
developers have the same set of capabilities in one place, without the need for constantly
switching tools. ƒ
 Faster development tasks: Tighter integration of all development tasks improves
developer productivity. For Example, code can be parsed and syntax checked while being
edited, providing instant feedback when syntax errors are introduced. Developers do not

9
need to switch between applications to complete tasks. In addition, the IDE’s tools and
features help developers organize resources, prevent mistakes and take shortcuts.
 Further, IDEs streamline development by encouraging holistic thinking. They enforce
developers to think of their actions in terms of the entire development lifecycle, rather
than as a series of discrete tasks. ƒ
 Continual learning: Staying up to date and educated is another benefit. For instance, the
IDEs topics are constantly being updated as well as new samples, project templates, etc.
Programmers who are continually learning and with current best practices are more likely
to contribute value to the team and the enterprise, and boost productivity.
 Standardization: The IDE interface standardizes the development process which helps
developers work together more smoothly and helps new hires get up to speed more
quickly.

6.6.3 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

Multi-language IDE

Multi-language IDEs such as Eclipse, NetBeans and Komodo support multiple programming
languages.

Figure 6.14 IDE software ƒ

10
 Eclipse: Supports C++, Python, PHP, Java and more. This free and open source editor
is model for many development frameworks. The eclipse began as a Java development
environment and has expanded through plugins. Eclipse is managed and directed by the
Eclipse.org Consortium. ƒ
 NetBeans: Supports Java, JavaScript, PHP, Python, Ruby, C, C++ and more. This
option is also free and open source. All the functions of the IDE are provided by modules
that each provide a well-defined function. Support for other programming languages can
be added by installing additional modules.

IDE for a specific application ƒ

 IDE for mobile development: There are IDEs specifically used for mobile development,
for instance, Android Studio and Visual Studio. ƒ
 HTML IDE: Some of the most popular IDEs are those for developing HTML
applications. For Example, IDEs such as HomeSite, DreamWeaver or FrontPage
automate many tasks involved in website development. ƒ
 Cloud-based IDE: Cloud IDEs give developers access to their code from anywhere.
For Example, Nitrous is a cloud-based development environment platform that supports
more than 40 languages including PHP, Ruby, Python, JavaScript with Node.js and Go

11

You might also like