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

CS-308:Programming Fundamentals

Dr. Sumaira Nishat


Book
Problem Solving
• We face/solve different problems everyday.
• Problem Solving is a process of identifying a problem and finding the
best solution for it.
• Different strategies, techniques (Flowchart, Algorithm, Program) and
tools are used to solve a problem.
Algorithms
• Algorithm is step by step procedure to solve a problem.
• Better to wrote algorithm before writing the actual computer
program.
• Algorithms are written in simple English called pseudocode.
• It is independent of any programming language.
• The steps of algorithm/pseudocode should be written sequentially.
• Program development in two main steps:
• Logic Design – The logic of the program is designed.
• Coding – The algorithm is converted into a program.
Algorithms - Example
• Algorithm to calculate sum of two numbers given by user. Display the
result also.
1. Start
2. Input A
3. Input B
4. Total = A+B
5. Display Total
6. End
Flowchart
• It is a graphical
representation of an
algorithm.
• It is a visual
representation of flow
of data, operations
performed on data and
sequence of these
operations.
• Flowchart Symbols:
Flowchart - Example
Algorithm to calculate sum of two numbers given by user. Display the
result also.
Example
• Algorithm to calculate sum of two numbers given by user. Display the
result also.
1. Start
2. Input A
3. Input B
4. Total = A+B
5. Display Total
6. End
Program
• Computers are used as a tool to solve complex problems by
developing computer programs (Software).
• Program/software is a set of instruction given to computer to solve a
problem.
• Programmer writes these instructions and computer execute these
instructions to solve a problem.
• Computer programs are written in programming language.
• Programmers use programming language
Program Development Process
1. Defining and analyzing Problem
2. Designing the Algorithm
3. Coding or writing the program
4. Testing Program
5. Final Documentation
Programming Language
• A set of words, symbols and codes used to write programs is called
programming language.
• Different programming languages are available for writing different
types of programs.
• There are two types of computer programming languages:
• Low-level languages
• High-level Languages
Low-level languages
• These languages are near to computer hardware and far from human
languages.
• Computer can understand these languages easily.
• Writing a program in low-level languages requires a deep knowledge
of the internal structure of computer hardware.
• Two low-level programming languages are
• Machine language- instructions are written in binary.
• Assembly language – symbols are used to write instructions.
High-level languages
• A type of language that is close to human language.
• Easy to understand.
• Instructions are written in English-like words such as input and print
etc.
• Divided into following categories:
• Procedural Languages – FORTRAN, BASIC, COBOL, C
• Object-Oriented Languages – C++, Java
• Non-Procedural Languages – SQL, RPG.
Types of Codes
• Source Code
• Program written in high-level language is called source code.
• Object Code
• A program in machine language is called object code.
Language Processor
• Computer understands only machine language.
• Program written in high-level or assembly language can not be run on
computer directly.
• It must be converted into machine language before execution.
• A language processor, or translator, is a computer program that
translates source code from one programming language (High-level
or assembly) to another (Machine language).
• Every computer Language has its own translator.
Language Processor
Compiler
• Converts instruction of high level language into machine language as
a whole.
• Compiler converts source code into object code.
Compiler
• Converts instruction of high level language into machine language as
a whole.
• Compiler converts source code into object code.
• Also checks syntax errors in the source code.
• A compiler can translate the programs of only that language for which
it is written. E.g. C Compiler can translate only those programs that
are written in C Language.
Interpreter
• Program that converts one statement of a program at one time.
• It does not produce an object program.
Assembler
• Program that translates the instruction of a assembly language into
machine language.

You might also like