Problems

8.1Write a function ‘exchange’ to interchange the values of two variables, say p and q. Illustrate the use of this function in calling program. Test the function for p = 4.5 and q = 7.3.
8.2Write a function to evaluate:

Illustrate its use in a calling program. Test the function for x = 2 and no. of terms = 20.

8.3The Fibonacci numbers are defined recursively as follows:
F1=1
F2=1
  
Fn=Fn−1 + Fn−2 when n > 2

Write a function that will generate and print the first ‘n’ Fibonacci numbers. Check the program to generate first10 Fibonacci numbers. Test the function for n = 10.

8.4Write a function that returns 1 if its argument is a prime number ...

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.