write a program in java to display the first 10 numbers of the series.1,-3,5,-7,9……..

0

write a program in java to display the first 10 numbers of  the series 1,-3,5,-7,9………..

asked April 8, 2015

2 Answers

0

public class Program {
public static void main(String args[])
{
int a=-1;
int n=1;
for(int i=0;i<10;i++)
{
a=a+2;
n+=1;
if(n%2==0)
{
System.out.println(a);
}
else
{
System.out.println(-a);
}
}
}

}

Your Answer