lab03 - CISC106 Fall 2009 Lab03 Review the code examples...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 m-file. 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(n-1) 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.

Page1 / 3

lab03 - CISC106 Fall 2009 Lab03 Review the code examples...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online