root@~ #cat 3.c
#include <stdio.h>
int main (void) {
float a=2.0,b=1.0,sum=0,t,i;
for(i=1;i<=3;i++) {
t=a/b;
printf ("a=%f b=%f t=%f",a,b,t);
b=a;
a=a+b;
sum=sum+t;
printf (" sum=%f\n",sum);
}
printf ("Result is %f\n",sum);
return 0;
}
root@~ #./3
a=2.000000 b=1.000000 t=2.000000 sum=2.000000
a=4.000000 b=2.000000 t=2.000000 sum=4.000000
a=8.000000 b=4.000000 t=2.000000 sum=6.000000
Result is 6.000000
root@~ #