Series18

Write a program to print the series 1/2, -2/3, 3/4, -4/5, 5/6,..........n/(n+1).

 

import java.util.*; class Series18 { public static void main() { System.out.println("Enter the number of terms to display in series \n"); Scanner in = new Scanner(System.in); int x = in.nextInt(); for(int i=1;i<x;i++) System.out.print((int)Math.pow(-1,(i+1))*i+"/"+(i+1)+", "); System.out.print((int)Math.pow(-1,(x+1))*x+"/"+(x+1)+". "); } }


For any desired program, please comment below. We will try our best to make that program available.

Comments

Popular Posts