HTTP/1.0 200 OK Content-type: text/html CSCI259

,6/5 19:59 CDT,Due date-->9/20/2000 10:00 CDT

  1. Check all the following statements that exit a function?
    1) continue 2) break 3) return 4) exit 5) goto

  2. What is returned from a subroutine called as a function e.g. sub()+6?
    1) int 2) void 3) nil 4) struct

  3. What is returned from a procedure call in which the () are omitted i.e. sub+6?
    1) int 2) void 3) nil 4) a function value

  4. What is returned from a function in which a return is never executed?
    1) syntax error 2) execution error 3) nil 4) a function value

  5. In x=sqrt(2.5), 2.5 is a
    1) argument 2) parameter 3) sub void 4) functoid

  6. In the definition function sqr(x), x is a
    1) argument 2) parameter 3) subarg 4) functoid

  7. In a procedure call with no arguments, are parentheses () required?
    1) yes 2) no

  8. Check all the following names that have local scope by default.
    1) a function's name
    2) a parameter
    3) a name declared in a function
    4) a name declared outside any function

  9. Check all the following names that have global scope.
    1) a function's name
    2) a parameter
    3) a name declared in a function
    4) a name declared outside any function

  10. function X(i, j, k) k=i j=k end
    i=1 j=2 k=3
    X(i,j,k)
    print(i, j, k)
    What prints?
    1) 123 2) 111 3) 213 4) 122

  11. What is a procedure prototype?

  12. Write the procedure prototype for the sqrt function in the math module.

  13. If you want to use a procedure before you define it (termed a 'forward reference'), what must you do first?

  14. Is a return of multiple values possible e.g return 5,6?
    yes no

  15. What is printed by the following code?
    function sum(x)
    return 5,4
    end --
    x=sum(42)
    print(x)

    1) 4 2) 5 3) 54 4) nil

  16. Is procedure overloading implemented?
    yes no

  17. What module contains sine and cosine functions?

  18. What module contains a random number function?

  19. Find the error and correct it in the following function that sums from 4 to x-1.
    function sum(x)
    if ( x<5 ) then return x
    else return x+sum(x)
    end --if
    end --sum

  20. For the previous question(after correction), what is the value returned by sum(42)?

  21. Write the prototype for a function that divides its two integer arguments and returns both the integer quotient and the integer remainder

  22. Now provide an implementation for the function in the previous question.

  23. Write an integer function that counts the number of even numbers between 9 and 101.

WARNING: There are only 20 answers to 23 questions.