You are on page 1of 12

BS MATH 2nd Semester

Programming Languages for Mathematicians


Lecture # 03

Yusra Hanif
Lecturer Computer Science
Concordia College Sahiwal
Lecture # 03 Concordia College Sahiwal 1
Summary of previous lecture

• Introduction to Operating system

• Getting started with C++

• Problem Solving

• Problem solving techniques

• What is Program?

• Programming Language

• Types of Programming language


Lecture # 03 Concordia College Sahiwal 2
Objectives

• Difference between high level and low level language

• Source code and object code

• What is Language processors or Translator?

• Types of Language processors

• Reasons to write program in high level language (C++)

Lecture # 03 Concordia College Sahiwal 3


Difference between high level & low level Language

High level Language Low level language

Easy to learn. Difficult to learn.

Near to human language. Far from human language.

Programs are slow in execution. Programs are fast in execution.

Easy to modify. Difficult to modify.

Deep knowledge of hardware is not required. Deep knowledge of hardware is required.

Used to write application programs. Used to write system software.

Many programmers. A few programmers,

Lecture # 03 Concordia College Sahiwal 4


Source code VS Object code
Source code:

“Program written in high level language”


(Source program)

Object code:

“Program written in low level language”


(Object program)
Lecture # 03 Concordia College Sahiwal 5
Difference b/w source & object code
Source Code Object code

Written in High level OR Assembly language. Written in low level language.

Easy to understand. Difficult to understand.

Easy to modify. Difficult to modify

Contains fewer statements than object code. Contains more statement than source code.

Lecture # 03 Concordia College Sahiwal 6


Language Processor OR Translator

• Computer understands only machine language.


• HL or assembly programs can’t run directly on computer.
• Must be converted in machine language before execution.

Definition:
“A type of system software that converts high level program in machine
language”.

Lecture # 03 Concordia College Sahiwal 7


Types of translators
• Compiler
• Interpreter
• Assembler

Compiler:
“A program that converts the instructions of a high level language into machine
language as a whole.”

Compiler converts source program into object code.


Checks each statement and generates machine code.
Checks syntax error.
Lecture # 03 Concordia College Sahiwal 8
Interpreter:
“Program that converts one statement of a program into machine code at one time.”

Executes a statement before translating the next statement.


If error in the statement, then it stops working & display error message.
Error is found immediately & programmer can correct them during program development.
Does not produce an object program.

Assembler:
Program that translates the instruction of assembly language into machine language.

Lecture # 03 Concordia College Sahiwal 9


Difference b/w compiler & interpreter
Compiler Interpreter

Converts the entire source code into machine code. Converts one instruction into machine code at one time.

Generates object code. Does not generate object code.

Program execution is fast. Program execution is slow.

Displays syntax error after compiling the whole Displays the syntax error on each instruction of the
program. program.

Lecture # 03 Concordia College Sahiwal 10


Reasons to write program in C++ language rather
than machine language

Two reasons to write program in C++ rather than machine language:

Easier to write program


Machine independence

Lecture # 03 Concordia College Sahiwal 11


Thank you!

Lecture # 03 Concordia College Sahiwal 12

You might also like