compute the nth mumber in the fibonacci sequence?
Answer Posted / selloorhari
// n th number of a fibonacci series
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,k = 0 , j = 1 ,n,res;
printf ( " \n enter the number " );
scanf ( "%d",&n ) ;
// printf ( "\n the series is 0, 1" ) ;
for ( i= 2 ; i<n;i++ )
{
res= k+j ;
k=j;
j=res;
// printf ( ", %d" ,res ) ;
}
printf ( " \n The n th term is %d " ,res ) ;
getch() ;
}
| Is This Answer Correct ? | 10 Yes | 1 No |
Post New Answer View All Answers
How we can insert comments in a c program?
application attempts to perform an operation?
What is dynamic variable in c?
Should a function contain a return statement if it does not return a value?
What are dangling pointers in c?
Define Spanning-Tree Protocol (STP)
What are the different data types in C?
How does #define work?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What is #include conio h?
What does 1f stand for?
Ow can I insert or delete a line (or record) in the middle of a file?
Why is main function so important?
Is anything faster than c?
What is the difference between struct and typedef struct in c?