Thursday, September 20, 2012

program for fibanosis series up to a limit

"program for fibanosis series up to a limit "

#include<conio.h>
#include<stdio.h>
void main()
{
int n,a=0,b=1,i=1,c;
clrscr();
printf("Enter the limit\n");
scanf("%d",&n);
if(n==1)
printf("%d",a) ;
if(n==2)
printf("%d,%d",a,b) ;
if(n>2)
{
printf("%d,%d,",a,b) ;
i=i+2;
while(i<=n)
{
c=a+b;
printf("%d,",c);
a=b;
b=c;
i++;

}
}
getch();
}

No comments:

Post a Comment