lecture 2
Program Development & Program Design Tools
by subhabrata das assam engineering college
Phases in Program Development
Phases in Program Development
Phases in Program Development
Phases in Program Development
Phases in Program Development
Phases in Program Development
Phases in Program Development
Phases in Program Development
Phases in Program Development
Phases in Program Development
Program Design Tools
Thevarioustoolscollectivelyreferredtoasprogra mdesigntools,thathelpsinplanningtheprogram are: Algorithm Flowchart Pseudo-code Decision Table
Algorithm
An algorithm is defined as a finite sequence of instructions defining the solution of a particular problem, where each instruction is numbered. However, in order to qualify as an algorithm, every sequence of instructions must satisfy the following criteria:
Input: There are zero or more values which are externally supplied. Output: At least one value is produced. Definiteness: Each step must be clear and unambiguous ,i.e. having one and only one meaning. Finiteness: If we trace the steps of an algorithm, then for all cases, the algorithm must terminate after a finite number of steps.
Algorithm
Formulate an algorithm to display the nature of roots of a quadratic equation of the type:
ax2+bx+c=0
provided
a0
Algorithm
Algorithm
Algorithm
Flowchart
Flowchart
Flowchart
Flowchart:Example
Practice Problem
Practice
Algorithm for finding the value of number m where m>=0
We all know m!=1*2*3*.*m Two things we can observe
we are repeatedly finding the product of two numbers at a time as shown below:
First time, product = 1*2 Second time, product = product *3 = 1*2*3 Third time, product = product *4 = 1*2*3*4 . .. (m-1)th Time, product=product*m = 1*2*3*4*.*m
Practice
Algorithm for finding the value of number m where m>=0
By introducing an initialize, we can reformulate the procedure as below:
Set product = 1 First time, product = 1*1(=1) Second time, product = product *2 = 1*2 Third time, product = product *3 = 1*2*3 . .. mth Time, product=product*m = 1*2*3*4*.*m
Practice
Algorithm for finding the value of number m where m>=0
Final Algorithm:
1. 2. 3. 4. 5. 6. 7. 8. Read m If ( m < 1 ) then go to step 8 Set product = 1 If (m = 0) then go to step 7 Repeat for k = 1,2,3..m product = product *k Print the value of product as the value of m! Stop
Pseudo-code
Pseudo-code
Pseudo-code
Pseudo-code
Pseudo-code
Pseudo-code
Pseudo-code
Pseudo-code
or Negative
Pseudo-code
Pseudo-code
Pseudo-code
Pseudo-code
Pseudo Code for m!
Algorithm: Pseudo-code
Begin Read : m If ( m > 0 ) then Set product = 1 Begin For k = 1 to m by 1 Set product = product*k EndFor End Print: product EndIf End
1. Read m 2. If ( m < 0 ) then go to step 8 3. Set product = 1 4. If (m = 0) then go to step 7 5. Repeat for k = 1,2,3..m 6. product = product *k 7. Print the value of product as the value of m! 8. Stop
Pseudo-code
Decision Table
Decision Table
Decision Table
Decision Table
Decision Table
Decision Table
Decision Table
Decision Table
Decision Table : Practice