Page 201 - Open Soource Technologies 304.indd
P. 201

Unit 8: Understanding Function and Procedure



               8.7 Summary


                  • User defined function can consists of one or more variables.
                  • Comparing function procedures with sub-procedures are invoked with call statements.
                  • Top-down design and structured programming emerged as techniques to enhance
                    programming productivity.

               8.8 Keywords


               Function procedure:  In addition to using built-in function, we can define function of our own.
               These new function, called function procedure or user-defined function.

               Future value function:  The value of an asset or cash at a specified date in the future that is
               equivalent in value to a specified sum today.
               Parameters: The variables appearing in the top line are called parameters.

               Region directive: The Region directive is used to make a program more readable or to create an
               outline for a program.

               Stepwise refinement: Repeatedly using a “divide-and-conquer” approach Repeatedly using a
               “divide-and-conquer” approach.


                              1. Suppose a program contains the lines

                                Dim n As Double, x As String
                                lstOutput.Items.Add(Arc(n, x))

                                What types of inputs (numeric or string) and output does the function Arc
                                 have?
                              2. Suppose a fixed amount of money is deposited at the beginning of each
                                 month into a savings account paying 6% interest compounded monthly.
                                 After each deposit is made, [new balance] = 1.005 * [previous balance one
                                 month ago] + [fixed amount]. Write a program that requests the fixed
                                 amount of the deposits as input and displays the balance after each of the
                                 first four deposits. A sample outcome when 800 is typed into the text box
                                 for the amount deposited each month follows.
                                              Month 1              800.00

                                              Month 2            1,604.00
                                              Month 3            2,412.02
                                              Month 4            3,224.08








                                      LOVELY PROFESSIONAL UNIVERSITY                        195
   196   197   198   199   200   201   202   203   204   205   206