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
Lists the benefits of c programming language?
How to declare a variable?
What is c system32 taskhostw exe?
How do c compilers work?
What are conditional operators in C?
Why do we use null pointer?
Why do we use header files in c?
What is 1d array in c?
What is c language used for?
Apart from dennis ritchie who the other person who contributed in design of c language.
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.
Is main a keyword in c?
Write a program for finding factorial of a number.
Tell me with an example the self-referential structure?
What are examples of structures?