Translate

Labels

Friday 21 June 2013

FIBONACCI SERIES USING ARRAYS

#include<stdio.h>
#include<conio.h>
main()
{
int a[30];
int x,n;
clrscr();
printf("Enter no.of times to print:");
scanf("%d",&n);
printf("\n FIBONACCI SERIES :");

a[0]=0;
a[1]=1;
printf("\n%d",a[0]);
printf("\n%d",a[1]);
for(x=2;x<n;x++)
{
printf("\n");
a[x]=a[x-1]+a[x];
printf("%d",a[x]);
}
getch();
}

OUTPUT:
Enter no.of times to print:5
Fibonacci series
0
1
1
2
3

No comments: