Advertisement
Realratnadwip

Fibonacci Series [till nth term]

May 16th, 2025 (edited)
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void main()
  5. {
  6.     int n, i, a, b, c;
  7.     printf("This is a simple program to generate Fibonacci Series.\n\n");
  8.     printf("Enter number of terms : ");
  9.     scanf("%d", &n);
  10.  
  11.     a = 0;
  12.     b = 1;
  13.  
  14.     printf("Fibonacci Series :\n");
  15.  
  16.     for(i = 1; i <= n; i++)
  17.     {
  18.         printf("%d ", a);
  19.         c = a + b;
  20.         a = b;
  21.         b = c;
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement