First time here? Checkout the FAQ!
x
menu search
brightness_auto
more_vert

Write a program to implement Fibonacci series upto n terms.

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
Best answer
#include <stdio.h>
int main() {

  int i, n;

 int t1 = 0, t2 = 1;

  int nextTerm = t1 + t2;

  printf("Enter the number of terms: ");
  scanf("%d", &n);

   printf("Fibonacci Series: %d, %d, ", t1, t2);

   for (i = 3; i <= n; ++i) {
    printf("%d, ", nextTerm);
    t1 = t2;
    t2 = nextTerm;
    nextTerm = t1 + t2;
  }

  return 0;
}
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
...