fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a=0, b=1, c, n;
  5. printf("No. of terms : \n");
  6. scanf("%d", &n);
  7. printf(" %d terms of Fibonacci series: \n", n);
  8. for(int i=0 ; i<n ; i++)
  9. {
  10. if(i<=1) c=i;
  11. else
  12. {
  13. c=a+b;
  14. a=b;
  15. b=c;
  16. }
  17. printf("%d " ,c);
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 5432KB
stdin
9
stdout
No. of terms : 
 9 terms of Fibonacci series: 
0  1  1  2  3  5  8  13  21