Computer Science, asked by Anonymous, 1 year ago

C Program to Display Fibonacci Sequence

Answers

Answered by ananthblaze
3

#include <stdio.h>

int main()

{

   int i, n, t1 = 0, t2 = 1, nextTerm;

   printf("Enter the number of terms: ");

   scanf("%d", &n);

   printf("Fibonacci Series: ");

   for (i = 1; i <= n; ++i)

   {

       printf("%d, ", t1);

       nextTerm = t1 + t2;

       t1 = t2;

       t2 = nextTerm;

   }

   return 0;

}

Similar questions