ITC Lect 06 (Algorithms Flowcharts Pseudocode-I)
ITC Lect 06 (Algorithms Flowcharts Pseudocode-I)
Flow Charts
Flowcharts – An Example
Find the solution of a quadratic equation
Ax2+Bx+C=0, given A, B and C.
A
START
INPUT X1 = (-B+R)/(2A)
A, B, C X2 = (-B-R)/(2A)
Calculate
PRINT
R = SQRT(B2-4AC) A, B, C, X1, X2
A
END
START
INPUT
Step 1: Begin the calculations A, B
BEGIN Adder
Step 2: Input two values A and B Input A and B
C = A + B
Add A to B
Step 3: Add the values PRINT C
and store in C
END Adder
Step 4: Display the result
OUTPUT
Step 5: End the calculation
C
END
Natural language Flowchart Pseudo-code
Ghulam Ishaq Khan Institute of Engineering Sciences and Technology, Topi
Lecture 06:Algo. Flowcharts Pseudocode CS 101: Introduction to Computing
Algorithm Representation
(Natural Languages)
Algorithm Representation
(Using Programming Language)
{
int I, m, Carry;
int a[100], b[100], c[100];
cin >> m;
for ( int j = 0 ; k <= m-1 ; j++ ) {
cin >> a[j];
cin >> b[j];
}
Carry = 0;
i = 0;
while ( i < m ) { …
Pseudo-code
• Pseudo-code
• Computer scientists use pseudo-code to express algorithms:
– English like constructs (or other natural language), but
– modeled to look like statements in typical programming languages.
Pseudo-code Primitives