#include<stdio.h>
int main(void)
{
int i,b=1;
double s;
s=0; /*s赋值*/
for(i=1;i<=15;i++)
{
s=s+double(i)/double(b);/*将整型强制变换成浮点型*/
b=b+2; /*进行循环*/
}
printf("sum = %f
" ,s);/*sum以浮点型输出*/
}
#include<stdio.h>
int main(void)
{
int i,b=1;
double s;
s=0; /*s赋值*/
for(i=1;i<=15;i++)
{
s=s+double(i)/double(b);/*将整型强制变换成浮点型*/
b=b+2; /*进行循环*/
}
printf("sum = %f
" ,s);/*sum以浮点型输出*/
}