-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatternPrinting1.java
More file actions
22 lines (18 loc) · 866 Bytes
/
patternPrinting1.java
File metadata and controls
22 lines (18 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;//input.
public class patternPrinting1 {// class Starting point...
public static void main(String[] args) { // publicStaticVoidMain Starting point...
Scanner scanner = new Scanner(System.in); //input.
System.out.print("Enter the value of n: ");//input.
int n = scanner.nextInt(); //input.
for (int i = 1; i <= n; i++) { // loop starting point
for (int j = 1; j <= n; j++) {
if (i == 1 || i == n || j == 1 || j == n) {
System.out.print("1 "); //printing 1...
} else {
System.out.print("0 "); //printing 0...
}
}
System.out.println();
} //loop ending point...
} // publicStaticVoidMain Ending point...
} // class Ending point...