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
What is the purpose of main() function?
Write a C program in Fibonacci series.
Write a c program to demonstrate character and string constants?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
explain how do you use macro?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
What are the header files used in c language?
Explain high-order bytes.
What are the advantages of using Unions?
What is the value of h?
What is difference between stdio h and conio h?
what is the different bitween abap and abap-hr?
What is meant by recursion?
Ow can I insert or delete a line (or record) in the middle of a file?