Wednesday, October 31, 2012

WAP to Print FIBONACCI SERIES 1,1,2,3,5,8,13,21....


/* Fibonacci Series,1,1,2,3,5,8,13,21........*/
#include<stdio.h>
#include<conio.h>
void main()
{
int temp=0,i,n,a,b;
clrscr();
printf("\nEnter Number where you want to stop: ");

scanf("%d",&n);

a=1;
b=1;

for(i=0; i<n; i++)
{
a=b;
b=temp;
temp=a+b;
printf("%d\n",temp);
}
getch();
}

No comments:

Post a Comment