main ()
{
int term,sum=1,deno;
do
{
deno=2;
term=1/deno;
sum=sum+term;
deno=deno+1;
}
while (deno<=10);
printf("the sum is %d",sum );
} 题目的意思是求1+1/2+1/3+……1/10
怎么就错了呢??
#include<stdio.h>
int
main (void)
{
float term,sum=1;
int deno=2;
do
{
term=1.0/deno;
sum=sum+term;
deno=deno+1;
}while (deno<=10);
printf("the sum is %f ",sum );
getch();
return 0;
}