This program generates the fibonacci series upto the number of terms which we desire. 'for' Control Structure is used.
LOGIC:
Fibonacci Series=Fn
were the seed values are
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n,x;
clrscr();
i=0;
j=1;
printf("Enter the number of terms:");
scanf("%d", &x);
printf("%d %d ",i,j);
for(n=0;n<=x;n++)
{
k=i+j;
i=j;
j=k;
printf("%d ",k);
}
getch();
}
LOGIC:
Fibonacci Series=Fn
were the seed values are
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n,x;
clrscr();
i=0;
j=1;
printf("Enter the number of terms:");
scanf("%d", &x);
printf("%d %d ",i,j);
for(n=0;n<=x;n++)
{
k=i+j;
i=j;
j=k;
printf("%d ",k);
}
getch();
}
No comments:
Post a Comment