Ch-09 (Comp) - Programming Languages

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

This book is compiled for all

BS/ADP disciplines. First 10


chapters (from page 1 to 205)
included in this book are
related to computer concepts
and other chapters are related
to the Windows 7, MS office
2010 (Word, Excel, PowerPoint,
Access), and InPage 2000 with
practical.
INTRODUCTION TO COMPUTER

Chapter 9
Programming Languages
Contents
• System & Information System
• Algorithm
• Pseudocode
• Flowchart
• Programming Languages
• Language Processor
System & Information System
Chapter 9 – Programming Languages
System & Information System
• A system is a combination of different related components that interact with
each other to perform some specific tasks.
• For example, the human circulatory system consists of blood, blood vessels,
and the heart.
• It makes blood flow to various parts of the body.
• The circulatory system interacts with other systems of the body to ensure that
the right quantity and composition of blood arrives in various body parts.
• An information system is similar to a physical system (such as the circulatory
system) except that an information system manipulates data rather than a
physical object like blood.
• An information system accepts data, processes it, and produces results
(output) for decision making.
System Development Life Cycle
• Process of developing a system (i.e. information
system) is called the system development life cycle
(SDLC).
• It is an organized way to develop a successful
system.
• It consists of different phases that are required to
develop a system.
• Each phase of the SDLC uses the results of the
previous one.
• The major phases of SDLC are planning, analysis,
design, implementation, and maintenance.
• Each phase is further divided into steps.

• Each phase is described in book “Introduction to Computer”


– PM Series
Algorithm
Chapter 9 – Programming Languages
Algorithm
• The step-by-step procedure to solve a problem is called an algorithm.
• It consists of a finite number of steps to solve a problem.
• The algorithm also shows the order of these steps for solving the problem.
• An algorithm is written in a natural language.
• So, it is easily understandable by other people.
• Notations for writing an algorithm
• START
• Input Description of each notation for writing an
• PRINT algorithm is given in book “Introduction to
• SET Computer” – PM Series
• IF-ELSE
• GOTO
• END
Examples of Algorithm
• Write an algorithm to find the sum, product, and average of two given
numbers.
• START
• INPUT first number in variable A
• INPUT second number in variable B
• INPUT third number in variable C
• Sum = A + B + C [ compute sum ]
• Product = A × B × C [ compute product ]
• Average = (A + B + C) / 3 [ compute average ]
• PRINT Sum
• PRINT Product
• PRINT Average
• END
Examples of Algorithm
• Write an algorithm to exchange the values of two variables.
• Write an algorithm to find a greater number of two numbers.

• For algorithms refer to book “Introduction to Computer” – PM Series


Pseudocode
Chapter 9 – Programming Languages
Pseudocode
• Pseudocode is a problem-solving tool.
• It is a generic way of describing an algorithm without the use of any specific
programming language syntax.
• All statements of Pseudocode are simple and straightforward.
• These statements represent the logic of the actual computer program in
natural language (like English language etc.).
• A Pseudocode is also called Program Design Language (PDL).
• Example:
• The following Pseudocode shows that a student is "passed" if he obtains
average marks greater than or equal to 50; otherwise "failed":
• If marks >=50
• Print "passed"
• Else
• Print "failed"
Flowchart
Chapter 9 – Programming Languages
Flowchart
• A graphical representation of the steps to solve a problem is called a
flowchart.
• It shows a step-by-step solution to a given problem.
• Different types of symbols are used in a flowchart.
• Each symbol represents a step to solve the problem and contains a short
description of the step.
• The flowchart symbols are connected with arrows (arrowhead lines).
• The arrows also show the flow of processing (i.e. the order of performing the
steps).
Flowchart
• Flowchart Symbols
• Flow Lines
• Terminal Description of each flowchart symbol is
• Input / Output given in book “Introduction to Computer”
– PM Series
• Processing
• Decision
• Pre-defined Process
• Connector
• Page Connector
• Remarks
• Basic Guidelines for Drawing a Flowchart
• Given in book
Examples
• Draw a flowchart to input two numbers,
calculate the sum, and print the result.

• Draw a flowchart to find a greater number


from two numbers A and B.
• Flowchart is given in book

• Draw a flowchart to print the even numbers


from 1 to 20.
Programming Languages
Chapter 9 – Programming Languages
Programming Languages
• A human language is a means of communication between two persons.
• Similarly, a programming language is a means of communication between user
and computer.
• A computer program is written in some programming language.
• Types of Programming Languages
• Machine language
• Assembly language
• High-level language
Programming Languages
Machine Language
• Low-level language
• Program’s instructions are written in binary form (in the form of 1s and 0s)
• First-generation language
• Machine-dependent
• Every computer has its own machine language
• Difficult to learn and use
Programming Languages
Assembly Language
• Middle-level language
• Near to the machine language
• Program’s instructions are written by using symbols (or short names) instead
of the binary form) → mnemonics
• Symbolic language
• Second-generation language
• The program written in assembly language cannot be run directly on the
computer
• It is translated into machine codes with the help of a translator program known as an
assembler
Programming Languages
High-Level Language
• Near to human languages
• Easy to learn and use
• Each high-level language has its own set of vocabulary and rules or grammar
for writing program instructions
• Each high-level language has its own translator program
• Not machine-dependent
• Examples → C, C++, C#, Java, Python, BASIC, COBOL, Pascal, FORTRAN, VB,
PHP, and ASP.NET
• Categories of high-level programming languages (Details are given in book)
• Procedural languages
• Non-Procedural Languages
• Object-Oriented Programming Languages
Language Processor
Chapter 9 – Programming Languages
Language Processor
• A program written in any high-level programming language or assembly
language is called source program
• The translated program into machine code is called object code
• A type of system software that translates the source code into machine code
(object code) is called a language processor. It is also called a language
translator.
• Every programming language (except machine language) has its own language
processor program.
• Types of language processors
• Compiler
• Interpreter
• Assembly
Language Processor
Compiler
• The language processor that translates the source code into machine code
(object code) as a whole is called a compiler.
• The translator programs of C and C++ languages are examples of compilers.
Language Processor
Interpreter
• The language translator that translates and executes the statements of a
source code one by one is called interpreter.
• It translates one statement of source code into machine code and executes it
immediately before translating the next statement.
• This process is continued up to the end of the program.
• If there is an error in any statement, the interpreter terminates its translating
process at that statement. It also displays an error message.
• The translator program of GWBASIC is an example of an interpreter.
Language Processor
Assembler
• The language processor that translates the program written in assembly
language into machine code is called assembler.

• Difference between compiler and interpreter is given in book


For more details, refers to

PM Series

Introduction to Computer

by
CM Aslam, Aqsa Aslam, Mussadiq Fida, & Mudassir
Ahmad

Publisher:Majeed Sons
22- Urdu Bazar, Lahore

You might also like