30 September, 2010

FIBONACCI SERIES IN C

#include<iostream.h>
#include<conio.h>
main()
{
const unsigned long limit=4294967295;
unsigned long next=0;
unsigned long last=1;
long sum;
clrscr();
cout<<”\n\nThis program will print the Fibonacci series :\n\n “;
while(next<limit/2)
{
cout<<last <<” “;
sum=next+last;
next=last;
last=sum;
}
getch();
}

29 September, 2010

FIBONACCI SERIES

#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c,i,n;
clrscr();
a=0;
b=1;
printf(“\n Enter n for how many times generate series”);
scanf(“%d”,&n);
printf(“\n FIBONACCI SERIES \n”);
printf(“\t%d\t%d”,a,b);
for(i=0;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf(“\t%d”,c);
}
getch();
};