Computer Programminglesson1
Computer Programminglesson1
PROGRAMMING
LESSON1
What is a Computer?
An electronic device that:
• accepts data (input),
• manipulates the data
(process),
• provides output (output) and
• stores the results (storage).
HE COMPUTER INFORMATION
ROCESSING CYCLE
Input c l
C y
ng
s i
e s
c
Output
P ro Process
on
ti
a
r m
Memory/Storage
f o
In
COMPUTER
PROGRAMMING?
Is the process of developing and
implementing various sets of
instructions to enable a computer
to do a certain task.
SOFTWARE
MAIN TYPES OF
Software(PROGRAMS)
There are two general types
of software.
•System software &
•Application software
SYSTEM SOFTWARE:
Operating Systems
The two operating systems most
users encounter are Microsoft
Windows and Mac OS X.
A programming language is an
artificial language that can be used to
control the behavior of a machine,
particularly a computer.
Programming languages
are used to facilitate
communication about the
task of organizing and
manipulating information,
and to express algorithms
precisely.
Computer Programming Languages
(Contd…): binary form
In order for a computer to be able to execute a
program, the program must first be present in
binary form within the computer's memory.
1011000111101
Advantage Machine
Language :
name "add"
mov al, 5 ; bin=00000101b
mov bl, 10 ; hex=0ah or bin=00001010b
add bl, al ; 5 + 10 = 15 (decimal) or
hex=0fh or
bin=00001111b
Advantages Assembly
Language:
1.The symbolic programming of Assembly Language is easier
to understand and saves a lot of time and effort of the
programmer.
2.It is easier to correct errors and modify program instructions.
3.Assembly Language has the same efficiency of execution as
the machine level language.
.
Disadvantages Assembly
Language:
1.One of the major disadvantages is that
assembly language is machine dependent.
33
High-level language
A programming language which use
statements consisting of English-like keywords
such as "FOR", "PRINT" or “IF“, ... etc.
Each statement corresponds to several
machine language instructions (one-to-many
correspondence).
Much easier to program than in assembly
language.
Data are referenced using descriptive names
Operations can be described using familiar
symbols
Example:
Cost := Price + Tax
Advantages of High Level
Languages
Higher level languages have a major
advantage over machine and assembly
languages that higher level languages are
easy to learn and use.
Example:
Machine Language (1's and 0's)
Assembly Language (Key words and
symbols)
Advantages and Disadvantages
of Low Level Languages:
It is not easy to
understand.
It is difficult to
modify.
High Level Languages:
The high level languages which are close to human languages.
they are easy to understand by Humans but difficult for
Computers to understand.
Computer needs some mechanism to understand them.
Example:
BASIC
PASCAL
FORTRAN
C/C++
python
JAVA etc.
Advantages and disadvantages of
High Level Languages
advantages of high level languages:
they are close to human being
they are easy to understand
They consist of English language like
structure
It does not depend upon machine
they are easy to modify
disadvantages of high level languages:
they need language translator to translate
into program in to machine language.
They do not execute directly on computer.
Programming Language levels
summary:
•.
Source Assembly
Program Compiler Language
Executable program
Output from linker/loader
Machine language program linked with necessary
libraries & other files
Files usually have extension ‘.exe’
Program Execution
Steps taken by the CPU to run a program
(instructions are in machine language):
1. Fetch an instruction
2. Decode (interpret) the instruction
3. Retrieve data, if needed
4. Execute (perform) actual processing
5. Store the results, if needed
Program Errors
Syntax Errors:
Errors in grammar of the language
Runtime error:
When there are no syntax errors, but the
program can’t complete execution
Divide by zero
Invalid input data
Logical errors:
The program completes execution, but delivers
incorrect results
Incorrect usage of parentheses
Compilation
Source Target
Program Compiler Program
Interpreter Output
Input
Java Compiler
bytecode
ML Interpreter