Computer Science, asked by saqlain111, 10 months ago

WAP to print the series 2/3-4/5+6/7-8/9......... n terms in java​

Answers

Answered by iamemma112358
1

import java.util.*;

class series

{ public static void main(String args[])

{Scanner sc=new Scanner(System.in);

int i,n,m=0,p=1;

double f=0.0;

System.out.println("Enter the value of n:");

n=sc.nextInt();

for(i=1,i<=n;i++)

{m=m+2;

p=p+2;

f=m/p;

c++;

if(c%2==0)

s=s-f;

else

s=s+f;}

System.out.println("Sum of series:"+ s);

}

}

Similar questions