Lect 7 Seq Logic Struct
Lect 7 Seq Logic Struct
• An algorithm is a set of instructions telling the computer how to process a module in a solution.
• Write an algorithm for each module in a program.
• A flowchart is a visual illustration of an algorithm. So draw a flowchart to accompany each
algorithm.
• The Pseudocode will follow the flowchart.
• The coupling diagram shows the relationship between the modules and the flow of data
• The data dictionary lists the variables and their definitions.
Sequential Logic Structure: In depth
• Algorithm Instruction : Start module name list of parameters (module number)
• Flowchart symbol:
• eg calculate_result(p,c,m)
Sequential Logic Structure: In depth
• Algorithm Instruction : Enter list of variable names
• Flowchart symbol:
• Definition (Action associated with the Instruction): Enter data from a data block or from the
keyboard into the following variable memory locations.
• eg enter out_of_mks
Sequential Logic Structure: In depth
• Algorithm Instruction : Variable = expression
• Flowchart symbol:
• eg total = p+c+m
perc = total * out_of_mks/100
Sequential Logic Structure: In depth
• Algorithm Instruction : Write list of variable names
• Flowchart symbol:
• Definition (Action associated with the Instruction): Write to the printer (output device) the
values represented by the following variable names.
• Flowchart symbol:
• Definition (Action associated with the Instruction): Execute the instructions in the named
module, and then return to execute the next instruction.
Sequential Logic Structure: In depth
• Algorithm Instruction : End/Exit
• Flowchart symbol:
• Flowchart symbol:
They will not be perfect the first time around and will often need several revisions.
Example of Sequential problem : All steps
Problem: Mary Smith is looking for the bank that will give the most return on her money over the
next five years. She has $2,000 to put into a savings account. The standard equation to calculate
principal plus interest at the end of a period of time is
where,
P Principal (amount of money to invest, in this case $2,000)
I Interest (percentage rate the bank pays to the investor)
N Number of Years (time for which the principal is invested)
M Compound Interval (the number of times per year the interest is calculated and added to
the principal)
Example of Sequential problem : All steps
Step 1: Problem analysis (Using Problem Analysis Chart)
• Understand what is needed and what is given.
• Separate them from all of the nonessential information in the problem.
• Write down the input in the Given Data section and the output in the Required Results section.
• Record the processing that the problem demands in the section of the problem analysis chart
headed Required Processing.
• Write possible solutions for the problem and any ideas related to the solution in the Solution
Alternatives section.
• Generate solution ideas through brainstorming and creative thinking.
Example of Sequential problem : All steps
Step 1: Problem analysis (Using Problem Analysis Chart)
Solution Alternatives
Enter all data as variables.
Enter principal and interest as constants and the other data as variables.
Process one bank in one run.
Process all banks in one run.
Example of Sequential problem : All steps
Step 1: Problem analysis (Using Problem Analysis Chart)
Solution Alternatives
Enter all data as variables.
Enter principal and interest as constants and the other data as variables.
Process one bank in one run.
Process all banks in one run.
Example of Sequential problem : All steps
Step 1: Problem analysis (Using Problem Analysis Chart)
Solution Alternatives
Enter all data as variables.
Enter principal and interest as constants and the other data as variables.
Process one bank in one run.
Process all banks in one run.
Example of Sequential problem : All steps
Step 2: Develop Interactivity chart
Decide various modules of the program
Given problem can be divides as:
1. The InterestControl module, which controls the solution
2. The Read module, which enters the data
3. The Calc module, which calculates the amount
4. The Print module, which prints the result
Example of Sequential problem : All steps
Step 3: Develop IPO chart from Problem analysis and Interactivity chart
How can the input be processed to achieve the required output?
Provide general instructions for the solution on the IPO chart.
Start with the output, next specify the input, and then develop the processing method required to
calculate the output from the input.