This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Understanding Iterations and Implementing Modular Programming
All candidates have to take three tests. A candidate is selected for the interview round based on the scores of all the three tests. The individual score in each test has to be greater than 75 and the average score across the three tests should be a minimum of 80. The call letter for the interview is to be sent to candidates who have been selected and a rejection letter is to be sent to the rest. Represent the logic for the above process by using a flowchart.
Understanding Iterations and Implementing Modular Programming
ExampleYou have been assigned the responsibility of generating an address list of all the people working in your office. For each person, you will need to accept the name, address, and the telephone number and print a list containing the collated details.
Understanding Iterations and Implementing Modular Programming
ExampleLet us look at the same example of preparing the test performance report in the decision-making section again. Now, apart from finding out whether a candidate has to be sent a call letter or a rejection letter, we also have to calculate the number of candidates who have been sent interview call letters and the number of candidates who have been sent rejection letters, using a flowchart.
Understanding Iterations and Implementing Modular Programming
Modular Approach to Programming A program needs to be amended periodically to
respond to changing conditions or requirements
This encouraged programmers to adopt a more disciplined approach to program writing.
The techniques that were adopted are known as structured programming techniques.
Structured programming includes features that are designed not only to solve the problem at hand but also to make the logic clear to someone reading the program
Understanding Iterations and Implementing Modular Programming
ExampleThe total expenditure on salaries for the month needs to be calculated. As per company policy an employee receives a minimum of $500. Depict the logic for automating the task by using flowcharts.
Program Variables to be used are:Variable Data Type Variable Name
Employee Code character cEmpCode
Employee salary numeric nSalary
Total salary numeric nTotSalary
Choice character cChoice
Understanding Iterations and Implementing Modular Programming
Problem Statement 3.P.4 Draw a flowchart that accepts input from a user and
displays the result, depending on whether the user wishes to multiply or divide the numbers provided as input. The Multiply module of the program can multiply maximum of three numbers. The Divide module of the program should check that the denominator should not be zero.
Understanding Iterations and Implementing Modular Programming
Summary (Contd.) Variable loops where the number of repetitions is not
known
Statements within a loop will be executed repeatedly until the condition becomes false
The structured programming technique is a disciplined approach to program writing.
A large program can be divided into several modules, where each module performs a specific task. A module is also called a procedure.
A procedure or a module is invoked from the main program and the control is returned from the procedure to the main program by using the return statement