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
What is a pragma?
Explain union.
What is use of integral promotions in c?
The statement, int(*x[]) () what does in indicate?
What is pointers in c?
Do character constants represent numerical values?
What is bubble sort technique in c?
How do you use a pointer to a function?
What is mean by data types in c?
What is bubble sort in c?
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
What is the difference between malloc() and calloc()?
Write a program to use switch statement.
How many levels of pointers can you have?
write a program to find out prime number using sieve case?