/* Sum of log series */
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int i=1;
float sum=0,term,x,accu,preterm;
printf("Enter the number for finding the log base e:");
scanf("%f",&x);
printf("Enter the accuracy:");
scanf("%f",&accu);
term=x-1;
preterm=term/i;
while(fabs(preterm)>accu)
{
preterm=term/i;
sum+=preterm;
term=term*(1-x);
i+=1;
}
printf("The value of log%.2f=%f\n",x,sum);
return(0);
}
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int i=1;
float sum=0,term,x,accu,preterm;
printf("Enter the number for finding the log base e:");
scanf("%f",&x);
printf("Enter the accuracy:");
scanf("%f",&accu);
term=x-1;
preterm=term/i;
while(fabs(preterm)>accu)
{
preterm=term/i;
sum+=preterm;
term=term*(1-x);
i+=1;
}
printf("The value of log%.2f=%f\n",x,sum);
return(0);
}
Comments
Post a Comment