1,333,55555........n terms write a java program using for loop
Answers
Explanation:
Program in Java to print series 5 55 555 5555 55555 555555
Output:
5 55 555 5555 55555 555555
Explanation:
Program in java to print given series:
Program:
public class Pattern //defining class Pattern
{
public static void main(String[] a) //defining main method
{
int x,y; //declaring variable
for (x = 1; i <= 6; i++) //loop for rows
{
for ( y = 1; j <= i; j++) //loop for columns
{
System.out.print("5"); //print value.
}
System.out.print(" "); //print space
}
}
}
Description of the above java program as follows:
In the above java program, a class that is Pattern is defined that contains the main method, inside the main method, two integer variable is declared that is x, and y, in which variable x is for print rows and variable y is used for print columns.
In this program two for loop is defined that is also known as nested loop, inside a loop both integer variable is used that print the given series.