Advertisement
P22DX

fn.c

Dec 17th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.     int i, n, t1 = 0, t2 = 1, nextTerm;
  4.     printf("Enter the number of terms: ");
  5.     scanf("%d", &n);
  6.     printf("Fibonacci Series: ");
  7.     for (i = 1; i <= n; ++i) {
  8.         printf("%d, ", t1);
  9.         nextTerm = t1 + t2;
  10.         t1 = t2;
  11.         t2 = nextTerm;
  12.     }
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement