11. Write a program to print the Fibonacci series with a given number.
#include <stdio.h>
#include <conio.h>
int fabin(int n)
{
if (n == 1)
return 0;
if (n == 2)
return 1;
else
return fabin(n - 1) + fabin(n - 2);
}
void main()
{
int a = 0, b = 1, n, i;
clrscr();
printf("Enter the No. of terms: ");
scanf("%d", &n);
printf("%d terms of fibonacci series is ", n);
printf("\n %d \t %d\t", a, b);
for (i = 3; i <= n; i++)
printf("%d\t", fabin(i));
}
Output
Enter the No. of terms: 10
10 terms of fibonacci series is
0 1 1 2 3 5 8 13 21 34