Fibonacci series is a series in which any number of the series is the sum of its previous
two numbers.
So , below is the Fibonacci series which we will be printing by using the below program.
(1, 1, 2, 3, 5, 8, 13, 21…………nth term) Here, we have taken three variables for the series x, y, z. We will add numbers and
then swap two numbers so that next value added gets changed and so, it forms the series.
Program
#include
<stdio.h>
#include
<conio.h>
void main()
{
int
x=0,y=1,z,n,i;
printf("Enter the nth term of series :");
scanf("%d",&n);
printf("%d\t",y);
for(i=1;i<n;i++)
{
z=x+y;
printf("%d\t",z);
x=y;
y=z;
}
}
Output:
Post a Comment