Computer Science, asked by Anonymous, 1 month ago

Print The Series In Java Upto 10 terms :
1, -3, 5, -7, 9

Answers

Answered by kamalrajatjoshi94
1

Answer:

Program:-

public class Main

{

public static void main(String args[])

{

int i,temp=1,temp1=-3;

System.out.println("The series:");

for(i=1;i<=10;i++)

{

if(i%2==0)

{

System.out.print(temp1+" ");

temp1=temp1-4;

}

else

{

System.out.print(temp+" ");

temp=temp+4;

}

}

}

}

Attachments:
Similar questions