Wap in java to find the sum of series:-
S=1/2-2/3+3/4.....nth term.
Answers
Answered by
2
Explanation:
import java.util.*;
class series
{
void main(String args[])
{
Scanner sc=new new Scanner (System.in);
System.out.println("Enter the terms");
int n=sc.nextInt();
double S=0.0;
for(int i=1;i<=n;i++)
{
if(i%2==0)
S=S-i/(i+1);
else
S=S+i/(i+1);
}
System.ou.println("Sum of the series='+S);
}
}
Similar questions