Translate

Labels

Friday, 28 December 2012

FIBONACCI SERIES

#include<stdio.h>
#include<conio.h>
void main()
{
int i, n;
int a=-1;
int b=1;
int c=0;
clrscr();
printf("Enter the number of terms to generate fibonacci series:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf("%d\n",c);
}
getch();
}

1 comment:

Arun Anoop M said...

#include
void main()
{
int i, n=7;
int a=0;
int b=1;
int c;
printf("%d\t%d\t",a,b);
for(i=2;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf("%d\t",c);
}
}