#include
void main()
{
int i, n;
float s=0.0;
scanf("%d", &n);
for (i = 1; i <= n; i ++)
s += 1.0/n/(n+1);
printf("%f\n", s);
}
#include "stdafx.h"
#include
#include
float f(int n)
{
float s=0.0;
for(int i=1;i<=n;i++)
{
s+=(float)1/(i*(i+1));
}
return s;
}
int _tmain(int argc, _TCHAR* argv[])
{
int n;
printf("Input an integer:");
scanf("%d",&n);
printf("calculating the sum now...\n");
printf("the sum is:%f\n",f(n));
system("pause");
return 0;
}
#include "stdafx.h"
#include
#include
float f(int n)
{
float s=0.0;
for(int i=1;i<=n;i++)
{
s+=(float)1/(i*(i+1));
}
return s;
}
int _tmain(int argc, _TCHAR* argv[])
{
int n;
printf("Input an integer:");
scanf("%d",&n);
printf("calculating the sum now...\n");
printf("the sum is:%f\n",f(n));
system("pause");
return 0;
}