compute the nth mumber in the fibonacci sequence?

Answer Posted / akshara

#include<stdio.h>
#include<conio.h>
void main()
{
int f=0,s=1,t,n,i;
clrscr();
printf("\nENTER THE VALUE OF N\n");
scanf("%d",&n);
if(n==1)
printf("FIBONACCI NUMBER IS 0");
else if(n==2)
printf("FIBONACCI NUMBER IS 1");
else
{
for(i=3;i<=n;i++)
{
t=f+s;
f=s;
s=t;
}
printf("\nFIBONACCI NUMBER IS %d",t);
}
getch();
}

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Lists the benefits of c programming language?

600


How to declare a variable?

575


What is c system32 taskhostw exe?

598


How do c compilers work?

613


What are conditional operators in C?

630






Why do we use null pointer?

609


Why do we use header files in c?

587


What is 1d array in c?

602


What is c language used for?

563


Apart from dennis ritchie who the other person who contributed in design of c language.

817


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3343


Is main a keyword in c?

636


Write a program for finding factorial of a number.

637


Tell me with an example the self-referential structure?

568


What are examples of structures?

601