Beruflich Dokumente
Kultur Dokumente
REPRESENTATION
23-Sep-19
1. Natural language
- usually lengthy and ambiguous.
19
Methods of Specifying
Algorithms...
3. Pseudo-code
- a mixture of natural language and programming language-like
23-Sep-19
structures
- precise and brief
- also avoids most issues of ambiguity
20
Algorithms In Natural
Language
• Easiest type of algorithms
• Written in natural language
23-Sep-19
• Also sometimes called un-structured algorithms
• These type of algorithms may be ambiguous and difficult to
21
Example 1
ALGORITHM To convert a decimal integer into binary
23-Sep-19
2. Divide by 2; write quotient and remainder
22
Example 2
ALGORITHM To mark attendance of students in a class
1. Start
23-Sep-19
2. Open attendance register
4. Check if student is present , mark ‘P’ , else mark the student as ‘A’
7. Stop
23
Example 3
Algorithm to find grade of a student
1. Read Total_Marks and Marks_Obtained
23-Sep-19
2. Calculate P=(Marks_Obtained/Total_Marks)/100
3. If P is less than 50 then Grade is “F”
23-Sep-19
• Start the Algorithm
• Ask The User to Enter any number
• Perform The Table Statements on each iteration (Multiply
25
Flow Chart
23-Sep-19
• Individual steps are represented by boxes and other shapes
on the flowchart, with arrows between those shapes
26
Start or stop
Process
Input or output
23-Sep-19
Decision
Off-page connector
27
Rules to draw a flowchart
• Every flowchart must have a start and stop symbol
• Symbols in a flowchart must be neat and clear
23-Sep-19
• The flow should be from top to bottom
• Isolated symbols cannot exist in a flowchart
28
Example 1
23-Sep-19
between 1 to 10