Computer Science, asked by nandisayari, 2 months ago

write a java program to print the series 0 3 8 15 till nth term​

Answers

Answered by keyboardavro
0

Answer:

Explanation:

The java program for the above question is as follows:

Explanation:

public class Series // Class definition

{

public static void main(String[] args)  // Main function declaration

{

int i=0,series=0,s=0; // variable declaration

while(i<10) // while loop to repeat the process 10 times.

{

    System.out.print(series+", "); // Print the series

    series=series+3+s; // Make the series

    i=i+1; // increment operator

    s=s+2; // increase for series

}

}

}

Output:

The user get "0, 3, 8, 15, 24, 35, 48, 63, 80, 99," as output because it is a series which is demand by the question.  

Code Explanation:

The above series is like this-- 0, 0+3, (0+3)+3+2, (0+3+3+2)+3+2 and so on.

Then the above program declares a while loop which executes 10 times.

Then it takes one variable which prints the value after adding the previous value and 3 and the s variable ( which starts from 0 and adds 2 value in previous value in every iteration of while loop).

Learn More:

Java program: brainly.in/question/3331693

Similar questions