Posted on Leave a comment

‘C’ Program for Fibonacci series

 ‘C’ program for Fibonacci series

  1. #include <stdio.h>
  2. int main()
  3. {
  4.   int n, first = 0, second = 1, next, c;
  5.   printf(“Enter the number of terms\n”);
  6.   scanf(“%d”, &n);
  7.   printf(“First %d terms of Fibonacci series are:\n”, n);
  8.   for (c = 0; c < n; c++)
  9.   {
  10.     if (c <= 1)
  11.       next = c;
  12.     else
  13.     {
  14.       next = first + second;
  15.       first = second;
  16.       second = next;
  17.     }
  18.     printf(“%d\n”, next);
  19.   }
  20.   return 0;
  21. }
Leave a Reply

Your email address will not be published. Required fields are marked *