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
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
What is difference between array and structure in c?
Does c have class?
which is an algorithm for sorting in a growing Lexicographic order
Is return a keyword in c?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
What is a lookup table in c?
What is || operator and how does it function in a program?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Explain Basic concepts of C language?
How main function is called in c?
Explain about block scope in c?
How can I change their mode to binary?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?