Answer to Question #134646 in C for Hana

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
1
Expert's answer
2020-09-23T08:05:22-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS