C program- To generate a fibonacci series

Posted: January 19, 2012 in Lab 2
#include<stdio.h>
int fibo(int *);
void main()
{
int d;
printf("Enter limit\n");
scanf("%d",&d);
fibo(&d);
}
int fibo(int *d)
{
int a=0,b=1,i,c;
printf("%d\n%d\n",a,b);
for(i=2;i<*d;i++)
{
c=a+b;
printf("%d\n",c);
a=b;
b=c;
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s