Tuesday, 19 November 2013

C-program to Generate Fibonacci series

#include<stdio.h>
main ()
{
int n,i,a=0,b=1,c;
printf("No.of terms needed in the series\t");
scanf("%d",&n);
printf("elements are \t");
for(i=0;i<n;i++)
{
if(i<=1)
c=i;
else
{
c=a+b;
a=b;
b=c;
}
printf("%d\t",c);
}
}


sakoncepts.blogspot.com
output


No comments:

Post a Comment