Square Pattern in Java
Java Programming Language Decision Making and Looping in java (Article) Decision Making and Looping in java (Program)
27
Given Input:
int rows = 5;
Expected Output:
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
Program:
class SquarePattern {
public static void main(String args[]) {
int rows = 5;
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= rows; j++) {
System.out.print("* ");
}
System.out.println();
}
}
}
Output:
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
Press any key to continue . . .
This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.
* * * * * * * * * * * * * * * * * * * * * * * * *
Program:
class SquarePattern { public static void main(String args[]) { int rows = 5; for (int i = 1; i <= rows; i++) { for (int j = 1; j <= rows; j++) { System.out.print("* "); } System.out.println(); } } }
Output:
* * * * * * * * * * * * * * * * * * * * * * * * * Press any key to continue . . .
This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.