JAVA program to print the series 0,3,8,15,24,35,48,63 upto 10 terms
Answers
Answered by
26
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: https://brainly.in/question/3331693
Answered by
4
Explanation:
import java.util.Scanner;
class Series
{
public static void main (String args[])
{
Scanner scan = new Scanner (System.in);
int d,i,n = 10;
for(i =1;i <=n;i++)
{
d=i*i-1;
System.out.print(d+" ");
}
}
}
Similar questions