Illustrative Solution for Lab #2 ~ problem #2 on page 33 in the Robertson text ~ with parameter passing PROBLEM STATEMENT You require an algorithm that will receive two integer items from a terminal operator [i.e., user], and display to the screen their sum, difference, product and quotient. DEFINING DIAGRAM Input integer1 integer2 STRUCTURE CHART Processing Get two numbers from user. Calculate their sum, difference, product and quotient. Display results. Output sum, difference, product, and quotient of numbers entered by user ALGORITHM EXPRESSED IN PSEUDOCODE: Basic_calculator (mainline) Get_numbers(integer1, integer2) Perform_operations(integer1, integer2, sum, difference, product, quotient) Report_results(sum, difference, product, quotient) END Get_numbers(integer1, integer2) Prompt for two integer values Get integer1 and integer2 from user END Perform_operations(integer1, integer2, sum, difference, product, quotient) Add(integer1, integer2, sum) Subtract(integer1, integer2, difference) Multiply(integer1, integer2, product) Divide(integer1, integer2, quotient) END Report_results(sum, difference, product, quotient) Display ‘the sum of the numbers is: ‘, sum Display ‘the difference of the numbers is: ‘, difference Display ‘the product of the numbers is: ‘, product Display ‘the quotient of the numbers is: ‘, quotient END ALGORITHM EXPRESSED IN PSEUDOCODE: (continued) Add(integer1, integer2, sum) sum = integer1 + integer2 END Subtract(integer1, integer2, difference) difference = integer1 - integer2 END Multiply(integer1, integer2, product) product = integer1 × integer2 END Divide(integer1, integer2, quotient) quotient = integer1 ÷ integer2 END
© Copyright 2026 Paperzz