1,-3,5,-7,9.......-19 write a java program
Answers
Answered by
0
public class series
{
public static void main(String args[])
{
int i,t=1;
for(i=1;i<=19;i=i+2)
{
System.out.print(i*t+",");
t=t*(-1);
}
}
}
Alternative way....
public class series
{
public static void main(String args[])
{
int i,x=1;
for(i=1;i<=10;i++)
{
if(i%2==1)
System.out.print(x+",");
else
System.out.print(x*(-1)+",");
}
}
}
mn121:
please mark it as brainliest .... ^_^
Similar questions