print 1,-3,5,-7,9 in bluej
Answers
Answered by
2
Import java.util.Scanner;
public class Series
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the value of n: ");
int n = sc.nextInt();
int k=-1;
for(int i=1;i<=n;i+=2)
{
k *= -1;
System.out.print((k*i)+" ");
}
}
}
public class Series
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the value of n: ");
int n = sc.nextInt();
int k=-1;
for(int i=1;i<=n;i+=2)
{
k *= -1;
System.out.print((k*i)+" ");
}
}
}
amira93:
mark as brainlist plz
Similar questions