//program to print fibonacci series
//By:-sujeet kumar
//0 1 1 2 3 5 8 ......
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a,b,c,i;
printf("Enter term of series\n");
scanf("%d",&n);
a=0;
b=1;
printf("\nFibonacci series\n");
printf("%d\n%d",a,b);
for(i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
printf("\n%d\n",c);
}
getch();
}
//By:-sujeet kumar
//0 1 1 2 3 5 8 ......
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a,b,c,i;
printf("Enter term of series\n");
scanf("%d",&n);
a=0;
b=1;
printf("\nFibonacci series\n");
printf("%d\n%d",a,b);
for(i=1;i<=n;i++)
{
c=a+b;
a=b;
b=c;
printf("\n%d\n",c);
}
getch();
}
No comments:
Post a Comment