#include<stdio.h> int main() { int k,n,temp; float sum=0,i=2.0,j=1.0; scanf("%d",&n); for(k=0;k<n;k++) { sum+=double(i/j); temp=i; i=i+j; j=temp; } printf("%0.2f",sum); return 0; } /* Main.c: In function 'main': Main.c:9:8: error: expected expression before 'double' sum+=double(i/j); ^ */ |
Double click to view unformatted code.