keepkoding
Question
ENTER THE Nth TERM 15 SUM OF SERIES=8
Code
import java.util.Scanner; public class Series { public static void main() { int n=0,i=0,sum=0; Scanner sc=new Scanner(System.in); System.out.println("ENTER THE Nth TERM"); n=sc.nextInt(); for(i=1;i<=n;i++) { if(i%2==0) { sum=sum-i; } else { sum=sum+i; } } System.out.println("SUM OF SERIES="+sum); } }
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Do you need help with your computer project or assignment?