fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int k,r;
  6. long int i=0,j=1,f;
  7. long int sum = 1;
  8.  
  9. printf("Enter the number range: ");
  10. scanf("%d",&r);
  11.  
  12. for(k=2;k<r;k++){
  13. f=i+j;
  14. i=j;
  15. j=f;
  16. sum = sum + j;
  17. }
  18.  
  19. printf("Sum of Fibonacci series is: %ld",sum);
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 9432KB
stdin
10
stdout
Enter the number range: Sum of Fibonacci series is: 88