Computer Science, asked by sp25, 1 year ago

Write a program in java to print the following pattern: S=1/2-3/4+5/6-7/8+................


sp25: త్వరగా జవాబు చెప్పండి రా

Answers

Answered by booklover19
3
public class series
{
public static void main (int n)
{
int p,d,s=0;
for(int I= 1;I<=n;I=I+2)
{
for(int j=2;j<=n;j=j+2)
{
if(I℅2!=0)
p=I*(-1);
else
p=I*1;
d=I/j;
s=s+d;
}
}
System.out.print(s);
}
}



Similar questions