Computer Programminglesson1 - Copy
Computer Programminglesson1 - Copy
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
COMPUTER
PROGRAMMING?
Is the process of developing and
implementing various sets of instructions
to enable a computer to do a certain task.
WHAT IS A COMPUTER
PROGRAM?
A computer program is a
sequence of instructions
written using a Computer
Programming Language
to perform a specified
task by the computer.
WHAT IS A Computer
Program?
A computer program is a collection
of step-by-step instructions that tell
the computer how to perform a
particular task or group of related
tasks.
PROGRAM IS ALSO KNOWN AS
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.
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.
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
Language translator
Language translator is a program that
translates a program of high level language
of computer understands only machine
language.
A program written in high-level or assembly
language cannot be run on a computer
directly.
It must be converted into machine
language before execution
Types of translators
Types of translators
Different types of translators or
language processors are
Compiler
Interpreter
Assembler
1. Compiler
Interpreter Output
Input
Java Compiler
bytecode
ML Interpreter
SUITABILIY OF A
PROGRAMMING LANGUAGE
FOR A TASK
4. Help with Enforcement of Correct
Code
The ideal programming language should
turn logic errors into syntax errors.