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
Can you explain the four storage classes in C?
What is a ternary operator in c?
How do you write a program which produces its own source code as output?
What are formal parameters?
With the help of using classes, write a program to add two numbers.
What are keywords in c with examples?
What is the size of enum in bytes?
How many keywords (reserve words) are in c?
What is getche() function?
Explain how can I avoid the abort, retry, fail messages?
What does the file stdio.h contain?
What does == mean in texting?
What is main () in c language?
What are the primitive data types in c?
Is printf a keyword?