0% found this document useful (0 votes)
46 views51 pages

ICT4

This document discusses concepts related to computer programming including: - A computer accepts data from a user, processes it, produces results, displays them, and stores them. - There are different languages for humans to communicate with computers, from machine language (binary) to programming languages like C++ and Java. - Computer programming involves creating instructions to allow a computer to perform a process. It includes designing, writing, testing, debugging code. - An algorithm is a sequence of instructions to solve a problem. Characteristics include being unambiguous, finite, and ordered. Flowcharts and pseudocode are used to design algorithms without using an actual programming language.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views51 pages

ICT4

This document discusses concepts related to computer programming including: - A computer accepts data from a user, processes it, produces results, displays them, and stores them. - There are different languages for humans to communicate with computers, from machine language (binary) to programming languages like C++ and Java. - Computer programming involves creating instructions to allow a computer to perform a process. It includes designing, writing, testing, debugging code. - An algorithm is a sequence of instructions to solve a problem. Characteristics include being unambiguous, finite, and ordered. Flowcharts and pseudocode are used to design algorithms without using an actual programming language.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

INFORMATION AND

COMMUNICATIONS
TECHNOLOGY IV
Concepts of Computer
Programming
A computer is an electronic device
that accepts data from the user,
processes it, produces results,
displays them to the users, and
stores the results for future usage.
How Humans Communicate with
Computers
Machine Language
(Binary 1,0)

Instructions
Programming
Language

Human Machine
Machine Language
Sometimes referred to as machine
code or object code, machine language is a
collection of binary digits or bits that the
computer reads and interprets. Machine
language is the only language a computer is
capable of understanding.
● Programming language is a set of words,
symbols and codes that enable human to
communicate with computers. There is a lot
of programming languages that exist

● Some examples are C, C++, C#, Java and


Perl. The process of creating program code
often requires expertise in program
algorithm, design, and logic
● The purpose of computer programming is
to create sets of instructions to enable a
computer to do a certain process.

● Its is the process of designing, writing,


testing, debugging, and maintaining the
source code of computer programs.
What is Algorithm?
Algorithm is a sequence of
unambiguous, finite and ordered
instructions to be followed to solve
a problem.
● It is a step-by-step procedure that defines a set
of instructions that must be carried out in a
specific order to produce the desired result.

● Algorithms are generally developed


independently of underlying languages, which
means that an algorithm can be implemented in
more than one programming language.
History of Algorithm
The word 'algorithm' itself is interesting. At first
glance, it appears to have some relation to the familiar
'logarithm' (by some permutation of the first four
characters!. However, it stems from the name of the
author of a famous Arabic textbook ( its original
Arabic text is lost; a Russian translation of a Latin
manuscript exists)' Abu Ja'far Mohammed ibn MOso-
al-Khoworizmi (A 0 825) who first suggested a
mechanical method for adding two numbers
represented in the Hindu positional number system.
The name transcribed in Latin became algorismus from
which algorithm was but a simple transformation. Of
course, the first non-trivial algorithm ever was devised
by the great Greek mathematician Euclid (between 400
and 300 B C) for finding the greatest common divisor
(gcd) of two positive numbers. The word 'algorithm' was
most often associated with this algorithm till 1950. It
may however be pointed out that several non-trivial
algorithms such as synthetic (polynomial) division have
been found in Vedic Mathematics which are dated much
before Euclid's algorithm.
● Problem: A problem can be defined as a
real-world problem or real-world instance
problem for which you need to develop a
program or set of instructions. An
algorithm is a set of instructions.
● Algorithm: An algorithm is defined as a
step-by-step process that will be designed
for a problem.
● Input: After designing an algorithm, the
algorithm is given the necessary and
desired inputs.
● Processing unit: The input will be passed
to the processing unit, producing the
desired output.
Computational process of algorithm ● Output: The outcome or result of the
program is referred to as the output.
The concept of an algorithm
constitutes the foundation for
information processing. It is
not only a familiar concept to
mathematicians but also
forms the foundation of
computer science. Two
striking features of
algorithms are: 1) an
algorithm is meant to be
executed and 2) objects
underlying an algorithm have
an associated meaning
Figure 1 A Computational process is similar to
the process of cooking.
Characteristics of an Algorithm
Characteristics of an Algorithm
● Input: An algorithm requires some input values. An algorithm
can be given a value other than 0 as input.
● Output: At the end of an algorithm, you will have one or
more outcomes.
● Unambiguity: A perfect algorithm is defined as unambiguous,
which means that its instructions should be clear and
straightforward.
● Finiteness: An algorithm must be finite. Finiteness in this
context means that the algorithm should have a limited number
of instructions, i.e., the instructions should be countable.
Characteristics of an Algorithm
● Effectiveness: Because each instruction in an algorithm
affects the overall process, it should be adequate.

● Language independence: An algorithm must be language-


independent, which means that its instructions can be
implemented in any language and produce the same results.
Why Do You Need an Algorithm?
You require algorithms for the following reasons:

1. Scalability
It aids in your understanding of scalability. When you have a sizable
real-world problem, you must break it down into small steps to
analyze it quickly.
2. Performance
The real world is challenging to break down into smaller steps. If a
problem can be easily divided into smaller steps, it indicates that the
problem is feasible.
Consider the process of cooking rice. Cooking is the
process carried out by a cook using the ingredients with
the help of utensils, cookers, oven and a recipe. The
ingredients are the inputs to the process, the cooked rice
is its output, and the recipe is its algorithm. That is, an
algorithm prescribes the activities that constitute a
process. The recipes (algorithms) are grouped under the
term software, whereas the utensils, cookers, and oven
are grouped under hardware. The process of cooking is
depicted in example no. 1.
Example 1: Let us look at a recipe for
cooking rice. It consists of the following
simple activities:

1 Put 1 cup of rice in the vessel of an electric rice-cooker.


2 Put 2 cups of water in the cooker vessel.
3 Close the lid of the cooker and switch it on.
4 Wait until the indicator light of the rice-cooker turns off.
Example 2: Add two numbers entered by
the user.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2 Step
5: Display sum Step
6: Stop
What is Flowchart?
Definition of Flowchart
 A flowchart is the graphical or pictorial
representation of an algorithm with the help of
different symbols, shapes and arrows in order to
demonstrate a process or a program.
 A flowchart should be used to see how a whole
process works. Flowchart identifies also the
critical points or problem areas in the process. It
also sees the different steps in the process.
Flowchart Example – Medical Service
This is a hospital flowchart example that shows how clinical cases shall be processed.
This flowchart uses decision shapes intensively in representing alternative flows.
What is Pseudocode?
• Pseudocode is an artificial and informal language
that helps programmers develop algorithms.
• Pseudocode is a "text-based" detail (algorithmic)
design tool.
• The rules of Pseudocode are reasonably
straightforward. All statements showing
"dependency" are to be indented. These include
while, do, for, if, switch
What is Pseudocode?
• It is a compact and informal high-level
description of a computer programming
algorithm that uses the structural conventions
of some programming language but is
intended for human-reading rather than
machine-reading.
What is Pseudocode?
• The purpose of using pseudocode is to provide a clear
and concise description of the steps that will be taken
in a process or algorithm without the need for specific
syntax or code. Pseudocode is not compiled or
executed on computers, it is only meant to be read and
understood by humans. Pseudocode is often used as a
tool to create, design, or plan algorithms and
prototypes.
Below will illustrate this notion.

Examples:
1.. If student's grade is greater than or equal to 60
Print "passed"
else
Print "failed"
Example 2: Calculate the Average of Five Numbers

START
INPUT five numbers and store them in variables num1, num2,
num3, num4, and num5
CALCULATE the sum of the five inputted numbers and store
them in variable sum
CALCULATE the average of the five inputted numbers and
store them in variable avg
PRINT the value of the variable avg
END
Advantages of Pseudocode
There are several advantages inherent to pseudocode
and its use. Some of these include:
 Pseudocode is a simple way to represent an
algorithm or program.
 It is written easily in a word processing application
and easily modified.
 Pseudocode is easy to understand and can be
written by anyone.
 Pseudocode can be used with various structured
programming languages.
Two Kinds of Programming Languages

 Low Level Programming Language

 High Level Programming Language


Low Level Programming Language
 A low-level language, often known as a computer's native language,
is a sort of programming language. It is very close to writing actual
machine instructions, and it deals with a computer's hardware
components and constraints. It works to control a computer's
operational semantics and provides little or no abstraction of
programming ideas. In contrast to high-level language that used for
developing software, low-level code is not human-readable, and it is
often cryptic. Assembly language and machine language are two
examples of low-level programming languages.
Low Level Programming Language
The major goal of the low-level language is to utilize high-level
languages like PHP, C#, and Swift to build software programmes and
scripts that operate, manage, and modify the computer's hardware
and instructions set architecture. The source code can be created
and edited by a software developer in a high-level language with the
help of using a basic text editor or a programming IDE. However, the
CPU cannot recognize the code directly. Before that, the code is
compiled into a low-level language.
Low Level Programming Language
Low-level languages are advantageous because programmes and
applications written in them may be executed directly on computer
hardware without the requirement for translation or interpretation. Also,
these applications and programs can run with a very minimal memory
footprint as well as very fast. However, they need a deeper knowledge of
machine language; therefore, they may be hard to use.
An assembly language comprises commands like ADD (add), SUB
(subtract), and MOV (move). These commands are responsible for
executing basic operations, such as performing calculations and moving
values into memory registers. By using an assembler, assembly language
can be translated into machine language.
Low-Level Programming Languages are sometimes
divided into two categories: first generation and
second generation.
1. First generation or machine language is a language system
that executed directly by a computer processing unit. Machine
language may be regarded as an extremely hardware dependent
programming language. Because of the tedious difficulty in
managing CPU resources, it is rarely used today, except for the
situation that requires the most extreme optimization.
Example of Binary Code
Example of Binary Code
2. Second generation or sometimes called Assembly
Language.
This refers to a class of low-level languages that are used to
write computer programs or to a particular language. It is
considered a second-generation language because while it is
not a microprocessors native language, an assembly language
programmer must still understand the microprocessor’s unique
architecture (such as its registers and instructions). These
simple instructions are then compiled directly into machine
code. The assembly code can also be abstracted to another
layer in a similar manner as machine code is abstracted into
assembly code.
An assembly language is a programming language that
communicates with the hardware of a computer directly. An
assembly language allows a software developer to code using
words and expressions that can be easier to understand and
interpret than the binary or hexadecimal data the computer
stores and reads. Assembly languages often serve as
intermediaries, allowing for developing more complex
programming languages, which can offer further efficiency to a
developer.
Example of assembly language
High-Level Programming Languages

1. High-level feature to express algorithms in a way


human does, rather than executing like the machines.
The limitation of the high-level language is that it
requires some programming skills to perform the
logical sequence of instructions. The very high level
languages were created so that users could solve this
common problem of a data processing easier and
faster.
High-Level Programming Languages

The main advantage of high-level languages over low-


level languages is that they are easier to read, write, and
maintain. Ultimately, programs written in a high-level
language must be translated into machine language by a
compiler or interpreter.
High-Level Programming Languages

3. The third generation languages are the first to use true


English which is much easier to use compare to other low
level language. Third generation language are portable,
the object code created for one type system can be
translated to another different type of system. Some
example are FORTRON, COBOL, Basic, Pascal, C, C++, and
Java.
High-Level Programming Languages

 Often abbreviated 4GL, fourth generation languages are


programming languages closer to human languages than
typical high-level languages. Most 4GL’s are used to access
databases such as database queries, report generators, data
manipulation, analysis and reporting, web development and
general purpose languages. Some example are Visual Basic
and other Visual environment.
 4GL’s are more user-friendly because of the use of icons,
graphical interfaces and the use of English words and phrases.
High-Level Programming Languages

Fifth generation languages are based on solving problems


using constraints given to the program, rather using an
algorithm written by a programmer. This way, the
programmer only needs to worry about what problems
need to be solved and what conditions need to be met,
without worrying about how to implement a routine or
algorithm to solve them. Fifth-generation languages are
used mainly in artificial intelligence and neural networks.

You might also like