Write a Java Program to find the sum of the given series:- S=2-4+6-8+........upto n
Answers
Answered by
3
Answer:
public class SumOfSeries{
public static void main(String args[]){
int n = 20;int sum =0;
for(int i=2;i<=n;i=i+2){
if(i%4==0){ sum=sum-i;}
else{ sum=sum+i;}
Similar questions
Social Sciences,
4 months ago
Chemistry,
4 months ago
Social Sciences,
8 months ago
English,
11 months ago
Math,
11 months ago