-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Java Program to Print Square Pattern | ||
|
||
import java.io.*; | ||
|
||
class GFG { | ||
|
||
static void print_rectangle(int k, int l) | ||
{ | ||
int a; | ||
int b; | ||
|
||
// Outer loop for rows | ||
for (a = 1; a <= k; a++) { | ||
// Inner loop for columns | ||
for (b = 1; b <= l; b++) { | ||
if (a == 1 || a == k || b == 1 || b == l) | ||
|
||
System.out.print("*"); | ||
else | ||
|
||
System.out.print(" "); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public static void main(String args[]) | ||
{ | ||
int rows = 8; | ||
int columns = 22; | ||
|
||
// Calling the method | ||
print_rectangle(rows, columns); | ||
} | ||
} |