Header Ads Widget

Responsive Advertisement

Fibonacci Series Using C Programming

#include <stdio.h>
 
void main()
 
{
 
  int a, b, c, i, n;
 
  a = 0;
  b = 1;
 
  printf("Enter a number to define the length of fibonacci series: ");
  scanf("%d", &n);
  printf("\nThe Series is: \n");
  printf("%d\t%d", a, b);
 
  for (i = 0; i < n; i++)
 
  {
 
    c = a + b;
 
    a = b;
 
    b = c;
 
    printf("\t%d", c);
 
  }
 
  getch();
 
}

-------------------------------
@@@@ OUTPUT @@@

Enter a number to define the length of fibonacci series: 5

The Series is:
0 1 1 2 3 5 8

Author

Post a Comment

0 Comments