Computer Programming

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Computer Programming

Week #5
Computer Programming
• Computer Programming: The key to successful use of a
computer is programming.
• Programming is the process by which a set of instructions
is written for a computer to perform some specific activity.
• Programming involves writing in sequence a set of
instructions that will produce a desired result when the
sequence is executed on the computer.
• The program is written by a programmer who uses a
variety of programming languages to communicate with
the computer.
Programming Languages
• A programming language consists of a set of vocabulary
and grammatical rules, to express the computations
and tasks that the computer has to perform.
• Programming languages are used to write a program,
which controls the behavior of computer, codify the
algorithms precisely, or enables the human-computer
interface.
• Each language has a unique set of keywords(words that
it understands) and a special syntax for organizing
program instructions.
Programming Languages
• A computer understands the language of 0’s
and 1’s, while the programmer is more
comfortable with English-like language.
• Programming language usually refers to high-
level languages like COBOL, BASIC, FORTRAN,
C, C++, Java etc.
Categories of programming languages

• Programming languages fall into two


categories according to their interpretation:

1. Low-level languages
2. High-level languages
Low-level languages
• Low level computer languages are machine codes or close
to it.
• Computer con not understand instructions given in high
level languages or in English.
• It can only understand and execute instructions given in
the form of machine language i.e. the language of 0 and 1.
• There are two types of low level languages:

1. Machine Language
2. Assembly Language
1.Machine language
• Machine language is what the computer can understand
but it is difficult for the programmer to 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 digit (bits) 0
and 1.
• The symbol 0 stands 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.
Machine language….
• Each kind of CPU has its own unique machine language.
• A machine language instruction consists of operation code and
one or more operands.
• The operation code specifies the operation that is to be
performed e.g. add, read etc. and the 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
languages by different translators.
Advantages and disadvantages of Machine
language
Advantages:
• It requires no translator to translate the code i.e. directly
understood by the computer
• Program written in machine language can be executed very fast.

Disadvantages:
• All operation codes 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.
2.Assembly language
• It was developed to overcome some of the many inconveniences
(problems/troubles/difficulties) of machine language.
• This is another low level but a very important language in which
operation codes and operands are given in the form of
alphanumeric symbols instead of 0’s and 1’s.
• These alphanumeric symbols will be known as mnemonic codes
and can have maximum up to 5 letter combinations e.g.
• ADD 2,3
• LOAD A
• SUB A, B
• Because of this feature it is also known as ‘Symbolic Programming
Language’.
Assembly language…..
• The program written is assembly language is the source
code, which has to be converted into machine code, also
called object code, using translator software, namely,
assembler.
• This language is also very difficult and needs a lot of
practice to master it because very small English support is
given to this language.
• Assembly language programs are generally written where
the efficiency and speed of program are the critical issues
i.e program requiring high speed and efficiency.
Advantages and disadvantages of 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.
Disadvantages:
• Like machine language it is also machine dependent.
• Since it is machine dependent therefore programmer
should have the knowledge of the hardware also.
High-level Languages
• A program in a high-level language is written in English-
like language.
• Such languages hide the details of CPU operations and
are easily portable across computers.
• A high-level language isolates the execution semantics
of computer architecture from the specification of the
program, making the process of developing a program
simpler and more understandable with respect to
assembly and machine level languages.
• Examples: C, C++, Java etc.
Advantages and disadvantages of High-level
languages
Advantages: Following are the advantages of a high level language:

• User – friendly (‘people based’).


• Similar to English with vocabulary words and symbols therefore it is easier to learn.
• They require less time to write.
• They are easier to maintain.
• ‘Problem oriented’ (to handle a particular class of problem) rather than ‘machine’
based.
• Shorter than their low – level equivalents. One statement translates into many machine
code instructions.
• Program written in a high – level language can be translated into many machine
language and therefore can run on any computer for which there exists and appropriate
translator.
• It is independent of the machine on which it is used i.e. programs developed in high
level language can be run on any computer.
Disadvantages: There are certain disadvantages also. In spite
these disadvantages, high – level languages have proved
their worth (value). The advantages out – weigh (greater
than) the disadvantages by far, for most applications.
These are:
• 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 as compared to an equivalent assembly
language program.

You might also like