Advertisement
saira12tabassum19

Untitled

Jul 1st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1.     /* Fibonacci series program in C language */
  2.     #include <stdio.h>
  3.      
  4.     int main()
  5.     {
  6.       int n, first = 0, second = 1, next, c;
  7.      
  8.       printf("Enter the number of terms\n");
  9.       scanf("%d", &n);
  10.      
  11.       printf("First %d terms of Fibonacci series are:\n", n);
  12.      
  13.       for (c = 0; c < n; c++)
  14.       {
  15.         if (c <= 1)
  16.           next = c;
  17.         else
  18.         {
  19.           next = first + second;
  20.           first = second;
  21.           second = next;
  22.         }
  23.         printf("%d\n", next);
  24.       }
  25.      
  26.       return 0;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement