Write a program using loop to input numbers and print the sum of the following series s=1^2-3^2+5^2-7^2+9^2-11^2
Answers
Answered by
0
Answer:
public class loop
{
public static void main(int n)
{
int i;int s=0;
for(i=1;i<=n;i=I+2)
{
if(i%2==0)
{
s=s+Math.pow(i,2);
}
else if(i%2!=0)
{
s=s-Math.pow(i,2);
}
}
}
}
Similar questions