new_stein
试试这个#include <stdio.h>
int main() {
// init var
float i_deno = 1, i_mole = 2;
// loop var
int i = 0, i_loopCtl = 1;
// result var
float f_sum = 0;
printf("How many items to calculate?\n");
scanf("%d", &i_loopCtl);
printf("The sum of the first %d terms will be calculated\n", i_loopCtl);
for (; i < i_loopCtl; i++) {
f_sum += i_mole/i_deno;
int i_tmp = i_mole;
i_mole += i_deno;
i_deno = i_tmp;
}
printf("The sum is : %f\n", f_sum);
return 0;
}