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


Please Help Members By Posting Answers For Below Questions

What is identifier in c?

535


What is pragma c?

607


Write a program to check armstrong number in c?

631


How will you delete a node in DLL?

677


What are directives in c?

539






how to write optimum code to divide a 50 digit number with a 25 digit number??

2745


Explain how do you view the path?

647


What is structure of c program?

597


What is null pointer in c?

587


Why should I prototype a function?

630


how can I convert a string to a number?

590


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.

594


What is the meaning of typedef struct in c?

584


What is local and global variable in c?

612


Explain do array subscripts always start with zero?

751