Computer Science, asked by kumaripriyanka88379, 7 months ago

program in java to generate 1,4,7,10........ numbers upto 10 terms​

Answers

Answered by Anonymous
0

Answer:here is ur code

import java.util.Scanner;

public class p16 {

public static void main(String[] args) {

 Scanner cs=new Scanner(System.in);  

 int n,i=1,se=1;

    System.out.println("Enter the range of number(Limit):");

    n=cs.nextInt();

   

    while(i<=n)

    {

        if(i%2==0)

        {

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

        }

        else

        {

         System.out.print(-1*se+" ");

        }

     se+=3;

     i++;

    }

     cs.close();

}

}

Explanation:

Similar questions