L1 Computer Program Introduction
L1 Computer Program Introduction
L1 Computer Program Introduction
1. Introduction to computers
A computer is a multipurpose electronic device that can receive process and store data.
They are used as tools in every part of society together with the Internet. Computers
nowadays are complex; there are a lot of different components inside them, and they
all serve different purposes. They all need to work together for the computer to work;
knowing how a computer works makes it easier to use a computer by being able to
understand how a computer will respond.
Computer
Computer Components
1- 1 Dr.Alyaa
Processing unit: processor CPU.
Software
Software is a generic term for organized collections of computer data and instructions,
often broken into two major categories:
System Software that provides task specific functions of the computer. System
software consists of an operating system and some fundamental utilities such as disk
formatters, file managers, display managers, text editors, user authentication (login)
and management tools, and networking and device control software.
Application Software which is used by users to accomplish specific tasks.
Application software may consist of a single program, such as an image viewer; such
as Microsoft Office, a software system such as a database management system.
1- 2 Dr.Alyaa
instructions that will automate the performance of a task for solving a given problem.
The process of programming thus often requires expertise in several different subjects,
including knowledge of the application domain, specialized algorithms, and
formal logic. Programs are written either in one of high-level programming languages
(such as BASIC, C, Java, pascal, matlab, python) which are easier but execute
relatively slowly, or in one of low-level languages (assembly language or
machine language) which are very complex but execute very fast.
Generally, we use languages like English, Hindi, and French etc., to make
communication between two persons. That means, when we want to make
communication between two persons we need a language through which persons can
express their feelings. Similarly, when we want to make communication between user
and computer or between two or more computers we need a language through which
user can give information to computer and vice versa. When user wants to give
any instruction to the computer the user needs a specific language and that
language is known as computer language. User interacts with the computer using
programs and that programs are created using computer programming languages like C,
C++, Java, etc. Computer Languages are classified into three languages :
1- 3 Dr.Alyaa
The following figure provides few key points related to the computer languages.
3. Language translators
1- 4 Dr.Alyaa
4. A computer program
In the form of a human-readable, computer programming language is called source
code Translators checks program syntax during translation process. The syntax of
a computer language is the set of rules that defines the combinations of symbols that
are considered to be a correctly structured document or fragment in that language.
Computer language syntax is generally distinguished into three levels:
Words – the lexical level, determining how characters form tokens;
Phrases – the grammar level, narrowly speaking, determining how tokens form
phrases;
Context – determining what objects or variables names refer to, if types are valid,
etc.
The meaning given to a combination of symbols is handled by semantics; the idea is
to examine these notions not from a programmer’s point of view but from the language
designer’s point of view.
5. Algorithm Definition
An algorithm is a set of instructions, sometimes called a procedure or a function that is
used to perform a certain task. This can be a simple process, such as adding two
numbers together, or a complex function, such as adding effects to an image. Most
computer programmers spend a large percentage of their time creating algorithms.
(The rest of their time is spent debugging the algorithms that don’t work properly.)
The goal is to create efficient algorithms that do not waste more computer resources
(such as RAM and CPU time) than necessary. This can be difficult, because an
algorithm that performs well on one set of data may perform poorly on other data. As
you might guess, poorly written algorithms can cause programs to run slowly and even
crash. Therefore, software updates are often introduced, touting “improved stability
and performance”. While this sounds impressive, it also means that the algorithms in
the previous versions of the software were not written as well as they could have been.
1- 5 Dr.Alyaa
A main benefit of the use of an algorithm comes from the improvement it makes
possible. If the problem solver does not know what was done, he or she will not know
what was done wrong. As time goes by and results are compared with goals, the
existence of a specified solution process allows identification of weaknesses and errors
in the process. Reduction of a task to a specified set of steps or algorithm is an
important part of analysis, control, and evaluation.
EXAMPLE:
1- 6 Dr.Alyaa
6. Flowchart Definition
1. Terminal: The oval symbol indicates Start, Stop and Halt in a program’s logic flow. A
pause/halt is generally used in program logic under some error conditions. Terminal is the
first and last symbols in the flowchart.
4. Decision Diamond symbol represents a decision point. Decision based operations such
as yes/no question or true/false are indicated by diamond in flowchart.
5. Connectors: Whenever flowchart becomes complex or it spreads over more than one
page, it is useful to use connectors to avoid any confusions. It is represented by a circle.
6. Flow lines: Flow lines indicate the exact sequence in which instructions are executed.
Arrows represent the direction of flow of control and relationship among different
symbols of flowchart.
1- 7 Dr.Alyaa
EXAMPLE1:
1- 8 Dr.Alyaa
EXAMPLE2:
Draw a flowchart to input two numbers from user and display the largest of two
numbers.
1- 9 Dr.Alyaa