Question

Please write both function PROTOTYPE and DEFINITION for the function. IN C PLEASE :P /* Line1:...

Please write both function PROTOTYPE and DEFINITION for the function. IN C PLEASE :P

/*

Line1: Describe the function/its purpose briefly

Line2: Describe the input parameters, or the assumptions/requirements going into the function

Line3: Describe the output of the function. (what does it return? what does it print?)

*/

3. Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2);

Where n is a positive integer n >= 0 and        

Fibonacci(1) = 1;        

Fibonacci(0) = 0;

0 0
Add a comment Improve this question Transcribed image text
Answer #1
// PROTOTYPE
long fibonacci(int);

// DEFINITION
/*
 * This function calculates the fibonacci of a given number
 * Input parameter n should be non-negative
 * This function returns the fibonacci of given number
 */
long fibonacci(int n) {
    if(n == 0) {
        return 0;
    } else if(n == 1) {
        return 1;
    } else {
        return fibonacci(n-1) + fibonacci(n-2);
    }
}
Add a comment
Know the answer?
Add Answer to:
Please write both function PROTOTYPE and DEFINITION for the function. IN C PLEASE :P /* Line1:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT