Home > Back-end >  O C a great god help!
O C a great god help!

Time:09-17

1 + 1/3 + 1/5 + programming: o... + 1/99 and, please use the for loop control statements,
Note: 1, set the variable for floating point, 2, and result output keep two decimal places

CodePudding user response:

Float sum=0.0;
for (int i=0; I & lt; 50; I++)
{
The sum +=(float) 1/(2 * I + 1);
}
Printf (" %. 02 f \ n ", sum);

CodePudding user response:

Such as 1/f, you can also use the sum +=1.0/(2 * I + 1);
  • Related