Professional Documents
Culture Documents
Introduction to Programming
BY:
SAYED WASIULLAH (SADAT)
1
WHAT IS COMPUTER PROGRAMMING?
Computer programming is defined as the
process of creating computer software using
a programming language.
Computer programs are written by Human
individuals (Programmers).
A computer program is a set of instructions
that tell a computer what to do.
A program is created using a programming
language.
2
Who is a Programmer?
A programmer is a person
who writes the required computer programs
or applications by giving the computer
specific programming instructions.
3
LANGUAGE?
Language is a source of communication among
people.
It is medium of Expression
What is the computer language?
To establish a communication between user and
computer .
In general, there are two classes of languages
Natural languages
Programming Languages
4
Natural languages
These are the languages through which the human beings
communicate with each other. For example: English, Urdu, French,
Pashto etc.
Programming languages
These are the languages through which the human beings
communicate with the computer. These are the most widely used
mediums between the user and the computer. Examples are
C(Compiler), C++, COBOL, PASCAL, BASIC, FORTRAN etc.
6
Main Points of Machine
language
The first language that was invented.
It is machine dependant.
It is also called binary language.
It is the most complicated and hard language.
A program created in machine language
cannot be run on any other computer
• Machine language depends on electric pulses
(i.e on / off).
7
ASSEMBLY LANGUAGE
The computer professionals developed one step higher
language than the machine language which is called
Assembly language .The binary codes of machine language
(0’s and 1’s) were replaced by some special codes called
mnemonics. The programs in Assembly language are written
using these mnemonic codes as: ADD for addition, SUB for
subtraction MUL for multiplication
8
Main points of Assembly
Language
it is one step easy then machine language.
It is also called symbolic language
(abbreviation are used).
It is machine dependent.
Slow and tedious language.
Special words are used as symbols called
MNEMONICS.
A program created on one computer cannot
run on another type of computer.
9
2) High Level Language
These languages are fairly
machine independent and English like.
10
Main Points of High Level
Language
It is English oriented language.
It is much easy to learn.
High level program is just like giving instruction
to a person in daily life.
High level program need preprocessor to
convert the program into machine codes.
Different types of programming languages are
FORTRAN, Pascal, C and C++ etc
11
The high level languages are of two types:
•Procedural languages/Structured languages.
•OOP (Object Oriented Programming) languages
12
Programming Language
Characteristics
Programming languages have some
characteristics that describe how they work and
provide information about the types of computing
tasks for which they are appropriate. When you
need to select a language to use for a program,
it is useful to understand some of the general
characteristics of programming languages and
the advantages or disadvantages of these
characteristics are given as
13
Characteristics of High Level
languages
The general characteristics of ‘High Level Languages’ are as follows
Machine Independence
High-Level languages are machine independent. This is a very
valuable advantage because it means that a program written in a
high-level language can be run on many different types of
computers with very little or practically no effort.
14
Fewer errors
In case of high-level languages, since the programmer need not
write all the small steps carried out by the computer, he is much
less likely to make an error. The computer takes care of all the
little details, and will not introduce any error of its own unless
something breaks down. Furthermore, compilers are so designed
that they automatically catch and point out the errors made by the
programmer. Hence diagnostic errors, if any, can be easily
located and corrected by the programmer.
15
Better documentation
A high-level language is designed in such a way that its
instructions may be written more like the language of the problem.
Thus the statements of a program written in a high-level language
can be easily understood by a person familiar with the problem.
For the documentation of such programs, very few or practically
no separate comment statements are required.
Easier to maintain
Programs written in high-level languages are easier to maintain
than assembly language or machine language programs. This is
mainly because they are easier to understand and hence it is
easier to locate, correct, and modify instructions as and when
desired. Insertion or removal of certain instructions from a
program is also possible without any compilation. Thus, major
changes can be incorporated with very little effort.
16
Language Translator
Translators are system programs, which translate programs written
in any high or assembly language into machine language (1’s and
0’s).
17
Language Translators
Assembler
The software that translates and assembly code into
the computer’s machine code is called assembler
18
Language Translators
Complier
A compiler is a computer software that translates a
whole program, called the source code at once into
machine code (object code)
Interpreter
An interpreter in another type of translator used for
translating a language program into machine code
It takes one statement of program and translates it
into a machine instruction which is immediately
executed by computer
--------------
--------------
------C-------
---program- Run on computer
--------------
--------------
---------------
20
Different types of Programs
Generally there are THREE types of
Programs that’s are created in a
programming Languages
Source Programs
Object Programs
Executable Programs
21
Source & Object Programs
Source Program:-The program which is written by the
user/programmer in a computer language is called source
program.
A Program that is created by user in a high level (C/C++)
language with the extension of CPP/C.
Object program:-The program which is converted into
machine understandable code by the compiler is called
object program.
A program that is created by the language processor in the
form of codes is called Object program.
A program that is converted in to object language (Machine)
is called object program
22
Executable Program
A program that is created by language processor
to show or provide the output of a source program.
A program that is directly run or executes to
provide results of the input.
A Program (software) that’s satisfy the user
requirements or provide the solution of the user
problem
Executable program:-When source and object program
are linked that’s create a new executable program is called
exe program.
23
First.C
-------------- C Files
--------------
-Source--
---program-
--------------
First.Obj
--------------
---------------
--------------
After --------------
Compilation -Object--
---Code----
--------------
--------------
--------------- First.Exe
After --------------
Linking --------------
-Executable--
---Code-
--------------
--------------
24
---------------