Problem 7
-
* -
* -
*
how to solve these pattern
Problem 7
*
*
*
how to solve these pattern
Hey @Ankitpal99
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int row = 1;
while (row <= n) {
if (row == 1 || row == n) {
for (int i = 1; i <= n; i++) {
System.out.print("* ");
}
} else {
for (int i = 1; i <= n; i++) {
if (i == 1 || i == n) {
System.out.print("* ");
} else {
System.out.print(" ");
}
}
}
System.out.println();
row++;
}
}
}
dry run this code