Introduction
  • In this article, I'm going to explain how to write the Fibonacci series.
Software Requirements
  • Turbo C++ OR C
Programming
  1. #include<stdio.h>
  2. void main()
  3. {
  4. int a,b,c,i,n;
  5. a=0;
  6. b=1;
  7. printf("Enter a no to define length of the series:");
  8. scanf("%d",&n);
  9. printf("\n The series is:\n");
  10. printf("%d\t%d",a,b);
  11. for (i=0;i<n;i++)
  12. {
  13. c=a+b;
  14. a=b;
  15. b=c;
  16. printf("\t%d",c);
  17. }
  18. getch();
  19. }
Explanation
  • In the above program, I have explained the logic of the Fibonacci series. The user can enter the length of the Fibonacci sequence and it will print on the output screen in a clear manner.

    programming
Output

Output