7. Program
7. How to Print this series ? 1, -4, 9, -25, 36, -49, 81.....N
import java.util.Scanner; class Series1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int i = 1, j=0; while(i <= n) { if(i%4 != 0) { j++; if(j%2 !=0) { System.out.print(i*i + ", "); } else { System.out.print(-(i*i) + ", "); } } i++; } } }