Friday, October 14, 2011

Write a C program to generate and print the first N Fibonacci numbers.

#include
main()
{
int a=0,b=1,c,n,d=0;
printf("Enter the value of N :");
scanf("%d",&n);
printf("%d Fibanocci numbers are :\n",n);
printf("%d\n",a);
printf("%d\n",b);
d=2; /*'0'and'1'are already used*/
while (d {
c=a+b;
d++;
printf("%d\n",c);
a=b;
b=c;
}
}

No comments:

Post a Comment