Dev Dives: Streamline document processing with UiPath Studio Web
Introduction to Computer Programming Lecture 12
1. Introduction to Computer
Lecture # 12
Course Instructor : Sehrish Rafiq
Govt. Girls Degree College Maneri Swabi
Higher Education Department KP
2. Lecture Overview
Problem Solving
Algorithm
Flow Chart
Programming
Computer Languages
Low Level Languages
High Level Languages
3. Steps of solving a problem
Identify, analyze and define the problem
Design algorithm
Draw Flow chart
Transform the algorithm in to a computer program
Test and debug the code
Execute and save the program
4. Algorithm
An algorithm is a step by step method of solving a problem.
It is a detailed series of instructions for carrying out an operation or solving
a problem.
Algorithms must have finite number of steps and should be completed in
finite time.
These steps / instructions should be carried out in sequence defined by the
programmer.
An algorithm should be defined in such a way that it reflect a clear picture
of the solution to the problem.
We use algorithms in everyday tasks also, such as a recipe to bake a cake or
plan for going to college.
5. Continued…
Algorithms do not follow any programming language.
They can be written in simple English or using special notation
(pseudocode symbols).
Algorithm cannot be executed on computer without converting it in
to program.
To make a computer do anything, the algorithm has to be converted
in to a computer program.
The computer then "executes" the program, following each step
mechanically, to accomplish the end goal.
6. Algorithm for adding two numbers
Step 1 :- Print “Enter any two numbers”
Step 2 :- Input a
Step 3 :- Input b
Step 4 :- Sum:= a + b
Step 5 :- Display Sum
Step 6 :- Exit
7. Flow Chart
A flow chart is a graphical or symbolic representation of the steps of
an algorithm.
Each step in the algorithm is represented by a different geometrical
symbol which contains a short description of the step.
These symbols are linked together with arrows showing the
algorithm flow.
10. Programming
Programming is the process of writing instructions in a particular
programming language for a computer to perform some specific activity.
These set of instructions are known as programs and are stored in
computer memory.
Before execution data and programs must be loaded in to RAM.
When programs are executed, they produce the desired result.
Program / set of programs are also known as software.
11. Program in C
# include< iostream.h >
#include< conio.h >
void main( )
{ int a, b, sum;
cout<<“Print any two numbers”<<endl;
cin>> a; cin>>b;
sum=a+b;
cout<< “Sum=”<<sum;
getch();
}
12. Computer Languages
Language is a source of communication between human beings.
Similarly, a programming language is a source of communication between
the programmer and computer.
A programming language is a vocabulary and set of grammatical rules for
instructing a computer or computing device to perform specific tasks.
Each programming language has a unique set of keywords (words that its
translator understands) and a special syntax for organizing program
instructions.
The programmers have to write their code according to the rules specified
by the particular programming language, they are using.
13. Continued…
There are two types of computer languages.
Low Level languages
High Level languages
15. Low Level Languages
Low level languages are machine codes or close to it.
They are machine dependent or hardware architecture dependent which
means that programs written in a low level language on one type of
computer cannot be executed on another type of computer.
There are two types of low level languages.
Machine Language
Assembly Language
16. Machine language
Machine language is the lowest and most elementary language and is the
first type of programming language developed.
Machine language is basically the only language which a computer can
understand.
In fact, a manufacturer designs a computer to obey just one language, its
machine code, which is represented inside the computer by a string of
binary digits (bits) 0 and 1.
The symbol 0 stand for the absence of an electric pulse and 1 for the
presence of an electric pulse.
Since a computer is capable of recognizing electric signals, therefore, it
understands machine language.
The set of binary codes which can be recognize by the computer is known
as its machine code instruction set.
17. Continued…
A machine language instruction consists of an operation code and one or
more operands.
The operation code specifies the operation to be performed e.g. read, record
etc.
Operands identify the quantities to be operated on e.g. the numbers to be
added or the locations where data are stored.
But, it is almost impossible to write programs directly in machine code.
For this reason, programs are normally written in assembly or high level
languages and then are translated in the machine language by different
translators.
18. Machine Language
Advantages
It makes fast and efficient use of the computer
It requires no translator to translate the code i.e. directly understood
by the computer.
Disadvantages
All operation codes have to be remembered
All memory addresses have to be remembered
It is hard to amend or find errors in a program written in the machine
language
These languages are machine dependent i.e. a particular machine
language can be used on only one type of computer.
19. Assembly Language
Assembly language was developed to overcome the problems of machine
language programmers.
In Assembly language operation codes and operands are given in the form
of alphanumeric symbols instead of 0’s and 1’s.
These alphanumeric symbols are known as mnemonic codes and can have
maximum up to 5 letter combinations e.g. ADD, SUB, MUL, DIV, JUMP,
LOAD, STORE, START, LABEL etc.
Assembly language is also known as “Symbolic Programming Language”.
Assembly language is also machine dependent like machine language which
means that assembly language code written for one machine cannot be
executed by another machine.
20. Continued…
This language is very difficult and needs a lot of practice to master it
because very small English support is given..
The instructions of the assembly language will also be converted to
machine codes by assembler to be executed by the computer.
21. Assembly Language
Advantages
It is easier to understand and use as compared to machine language.
It is easy to locate and correct errors.
It is modified easily as compared to machine language.
Disadvantages
Like machine language it is also machine dependent
Since it is machine dependent, there programmer should have the
knowledge of he hardware also.
22. High Level Language
High level computer languages give formats close to English language.
The purpose of developing high level languages is to enable people to
write programs easily and in their own native language environment
(English).
High-level languages are basically symbolic languages that use English
words and/or mathematical symbols rather than mnemonic codes.
Each instruction in the high level language is translated into many
machine language instructions thus showing one-to-many translation.
Examples of High Level Languages are :- C, C++,C#, Java, Python etc.
23. Advantages
User-friendly (people based).
Similar to English with vocabulary of words awl symbols therefore it is
easier to learn.
They require less time to write.
They are easier to maintain.
Problem oriented' rather than 'machine' based.
Shorter than their low-level equivalents, One statement translates into
many machine code instructions.
It is independent of the machine on which it used i.e. programs developed
in high level language can be run on any computer for which there exists an
appropriate translator.
24. Disadvantages
A high-level language has to be translated into the -machine language by a
translator and thus a price in computer time is paid.
The object code generated by a translator might be inefficient compared to
an equivalent assembly language program.