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 identifier in c?
What is pragma c?
Write a program to check armstrong number in c?
How will you delete a node in DLL?
What are directives in c?
how to write optimum code to divide a 50 digit number with a 25 digit number??
Explain how do you view the path?
What is structure of c program?
What is null pointer in c?
Why should I prototype a function?
how can I convert a string to a number?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
What is the meaning of typedef struct in c?
What is local and global variable in c?
Explain do array subscripts always start with zero?