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
which is an algorithm for sorting in a growing Lexicographic order
What is console in c language?
Differentiate between Macro and ordinary definition.
List a few unconditional control statement in c.
Explain how can I convert a string to a number?
How can I write a function that takes a format string and a variable number of arguments?
What is the condition that is applied with ?: Operator?
shorting algorithmS
If null and 0 are equivalent as null pointer constants, which should I use?
What is a node in c?
What are different types of variables in c?
Explain what is the difference between #include and #include 'file' ?
How can I read data from data files with particular formats?
What is wrong with this initialization?
What does double pointer mean in c?