#include
main()
{
int n,sign=1,i;
double sum=0.0;
printf("Enter n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum+=sign*1.0/i;
sign=-sign;
}
printf("sum=%lf\n",sum);
}
#include
void main()
{
int n,i;
float sum=0.0;
printf("Please enter n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%2==1) sum+=1.0/i;
else sum-=1.0/i;
}
printf("sum=%lf\n",sum);
}