Computer Programming and Problem Solving
Computer Programming and Problem Solving
Fundamentals of Computer
Programming and Problem Solving
[Information Technology]
Extra Material
Fundamentals of Computer Programming and Problem Solving
1. Introduction 2
2. Algorithm 2
3. Flow chart 2
4. Pseudo Code 3
5. Control Structure 4
7. Programming languages 6
1. ALGORITHM
An algorithm is a step-by-step procedure used for solving a problem or performing a
computation.
Example 1.1
Algorithm for addition of two numbers
Step1: Start
Step 2: Input A, B
Step 4: Output C
Step 5: Stop
2. FLOW CHART
Flowchart is a diagrammatic way of representing an algorithm.
Symbols used in a flow chart:
Parallelogram Input/output
Rectangle Processing
Circle Connector
Start
Input A, B
C=A+B
Print C
Stop
Start
Input a
Input b
Sum = a+b
Output sum
Stop
a. ALGORITHM:
Step 1: Start
Step 2: Input the values of A, B
Step 3: If A > B then go to step 5
Step 4: Print “B is largest” go to Step 6
Step 5: Print “A is largest”
Step 6: Stop
b. FLOW CHART:
Start
Input A, B
True False
A>B
Print B
Print A bA
Stop
Algorithm and flow chart for display of first 5 natural numbers using control structure while.
a. ALGORITHM:
Step 1: Start
Step 2: Set i= 1
3.1: Output i
3.2: i = i+1
Step 4: Stop
b. FLOW CHART:
Start
i=1
False
i <= 5
True
Stop
Print i
i= i + 1
7.1 Compiler:
Compiler is a program that translates a high-level language into machine level language.
7.2 Interpreter:
Interpreter is a program that translates a high-level language into machine level language line by line.
# Compiler Interpreter
Compiler Takes Entire program as input Interpreter Takes Single instruction as input.
1
Program execution is fast Program execution is relatively slow
2
Example: C Compiler Example: BASIC
3