Answer to Question #134510 in C for Mario

Question #134510
Create a C program that display the Fibonnacci number(s).

The program must ask an input of nth-Fibonacci.

Example:

Find fibonacci number: 5th

5th-Fibonacci = 3
1
Expert's answer
2020-09-22T10:36:10-0400
#include <stdio.h>


// Function to find n'th Fibonacci number
int fib(int n)
{
	if (n <= 1)
		return n;


	return fib(n - 1) + fib(n - 2);
}


int main()
{
	int n;
    printf("Enter number\n");
    scanf("%d",&n);
	printf("%dth-Fibonacci number is %d", n, fib(n));


	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS