This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CISC106 Fall 2009 Lab03 Review the code examples from class. Some programs below are associated with a question. Answer the questions using comments below your code in the mfile. The office hours of the TAs and the instructor are on the class website. Visit us! NOTE: Every function comment section should contain, at a minimum, three examples of the function being called and the result of evaluating the call. These examples must include boundary conditions (as discussed in class). Your test files must cover at least these exact examples (other wise, why did you choose them?) and possibly more. Testing is important. Problems 1. files: fact.m, factTest.m Write a recursive MATLAB function fact that takes a positive integer n as argument, and returns fact(n) as defined: fact(n) = ( n, if n < = 2 the product of n and fact(n1) otherwise. Thus fact(4) evaluates to 24. After you write fact, write a test function that tests it. Demonstrate the test function in a diary file. 2. files: expt.m, exptTest.m Review your notes from class where we discussed what every recursive function needs to work correctly. Now write a recursive function to calculate the positive integer exponent of an integer, according to the following definition: expt ( base,exponent ) = { base, if exponent is one ; base * expt ( base, exponent 1) otherwise....
View
Full
Document
This note was uploaded on 10/07/2009 for the course CISC 106 taught by Professor Mcgeary during the Fall '08 term at University of Delaware.
 Fall '08
 McGeary

Click to edit the document details