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


Please Help Members By Posting Answers For Below Questions

What is a pragma?

672


Explain union.

641


What is use of integral promotions in c?

668


The statement, int(*x[]) () what does in indicate?

649


What is pointers in c?

662






Do character constants represent numerical values?

848


What is bubble sort technique in c?

594


How do you use a pointer to a function?

638


What is mean by data types in c?

557


What is bubble sort in c?

640


any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above

663


What is the difference between malloc() and calloc()?

619


Write a program to use switch statement.

662


How many levels of pointers can you have?

708


write a program to find out prime number using sieve case?

1646