View All C Programs

 Previews Example  View All C Programs Next Example 

Program to Display Fibonacci Series in c

#include <stdio.h>
#include <conio.h>
 main()
{
  int n, a=0, b=1, c=0;
  printf("Enter number of terms: ");
  scanf("%d",&n);
  printf("Fibonacci Series: %d+%d+", a, b); /* Displaying first two terms */
  for(int i=1; i<=n; i++)
  {
      c=t1+t2;
      a=b;
      b=c;
      printf("%d+",c);
  }
  getch();
}
Result
Enter number of terms: 9
Fibonacci Series: 0+1+1+2+3+5+8+13+21+