/*THE NATURAL LOGARITHM CAN BE APPROXIMATED BY THE FOLLOWING SERIES: (x-1/x)+[1/2(x-1/x)*(x-1/x)]+[1/2(x-1/x)*(x-1/x)*(x-1/x)].....upto 7 terms. IF x IS INPUT THROUGH THE KEYBOARD, WAP OT CALCULATE SUM OF THE SREIES*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int x;
int i;
float sum=0;
clrscr();
printf("\nEnter the value of x= ");
scanf("%d",&x);
if(x!=0)
{
for(i=1;i<=7;i++)
{
if(i==1)
sum=sum+pow(((x-1.0)/x),i);
else
sum=sum+(1.0/2)*pow(((x-1.0)/x),i);
}
printf("\nSum of the given series= %f",sum);
}
else
printf("\n\tERROR.\n\tYou have entered a wrong input.");
getch();
}