View Code of Problem 48

#include <stdio.h>
 int main()
 {
   int n;
   scanf("%d", &n);
   float a, b, c, i, t = 0;
   double sum=0;
   if(n>=1&&n<=10){
     a = 1;
     b = 2;
     sum = b/a;
     for(i=1;i<n;i++){
        c = a + b;
        sum += c/b;
        t = b;
        b = c;
        a = t;
     }
  printf("%.6f", sum);
}
/*
Main.c: In function 'main':
Main.c:20:1: error: expected declaration or statement at end of input
 }
 ^
*/

Double click to view unformatted code.


Back to problem 48