Question #134646

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

Expert's answer

#include<stdio.h>

int main()

{

int term1=0, term2=1, nextTerm=0, nthterm, last;

printf(" Please enter the nth-fibonacci ");

scanf("%d", &nthterm);

nextTerm=term1+term2;

while(nextTerm<nthterm)

{

term1=term2;


term2=nextTerm;

nextTerm=term1+term2;

}

printf("%d",term2);

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!

LATEST TUTORIALS
APPROVED BY CLIENTS