Program to Print Mirrored Hollow Parallelogram
Given the length as rows and breadth as cols, the task is to print the mirrored hollow parallelogram.
Examples:
Input: rows = 5, cols = 8
Output:
********
* *
* *
* *
********
C++
// CPP program to print hollow mirrored // parallelogram star pattern series #include <iostream> using namespace std; // function for creating pattern void Pattern(int rows, int cols) { int i, j; for (i = 1; i <= rows; i++) { // Printing spaces for (j = 1; j < i; j++) { cout << " "; } // Printing hollow parallelogram for (j = 1; j <= cols; j++) { if (i == 1 || i == rows || j == 1 || j == cols) { cout << "*"; } else { cout << " "; } } cout << "\n"; } } // driver code int main() { // Get number of rows and columns int rows = 5, cols = 8; // Print the Pattern Pattern(rows, cols); return 0; } |
chevron_right
filter_none
C
// C program to print hollow mirrored // parallelogram star pattern series #include <stdio.h> // function for creating pattern void Pattern(int rows, int cols) { int i, j; for (i = 1; i <= rows; i++) { // Printing spaces for (j = 1; j < i; j++) { printf(" "); } // Printing hollow parallelogram for (j = 1; j <= cols; j++) { if (i == 1 || i == rows || j == 1 || j == cols) { printf("*"); } else { printf(" "); } } printf("\n"); } } // driver code int main() { // Get number of rows and columns int rows = 5, cols = 8; // Print the Pattern Pattern(rows, cols); return 0; } |
chevron_right
filter_none
Java
// Java program to print hollow mirrored // parallelogram star pattern series import java.util.*; class solution { // function for creating pattern static void Pattern(int rows, int cols) { int i, j; for (i = 1; i <= rows; i++) { // Printing spaces for (j = 1; j < i; j++) { System.out.print(" "); } // Printing hollow parallelogram for (j = 1; j <= cols; j++) { if (i == 1 || i == rows || j == 1 || j == cols) { System.out.print("*"); } else { System.out.print(" "); } } System.out.print("\n"); } } // driver code public static void main(String args[]) { // Get number of rows and columns int rows = 5, cols = 8; // Print the Pattern Pattern(rows, cols); } } |
chevron_right
filter_none
Python3
# Python3 program to prhollow mirrored # parallelogram star pattern series import math as mt # function for creating pattern def Pattern(rows, cols): for i in range(1, rows + 1): # Printing spaces for j in range(1, i): print(end = " ") # Printing hollow parallelogram for j in range(1, cols + 1): if (i == 1 or i == rows or j == 1 or j == cols): print("*", end = "") else: print(end = " ") print() # Driver code # Get number of rows and columns rows, cols = 5, 8 # Prthe Pattern Pattern(rows, cols) # This code is contributed by # mohit kumar 29 |
chevron_right
filter_none
C#
// C# program to print hollow mirrored // parallelogram star pattern series using System; class GFG { // function for creating pattern static void Pattern(int rows, int cols) { int i, j; for (i = 1; i <= rows; i++) { // Printing spaces for (j = 1; j < i; j++) { Console.Write(" "); } // Printing hollow parallelogram for (j = 1; j <= cols; j++) { if (i == 1 || i == rows || j == 1 || j == cols) { Console.Write("*"); } else { Console.Write(" "); } } Console.Write("\n"); } } // Driver code public static void Main() { // Get number of rows and columns int rows = 5, cols = 8; // Print the Pattern Pattern(rows, cols); } } // This code is contributed by RAJPUT-JI |
chevron_right
filter_none
PHP
<?php // PHP program to print hollow mirrored // parallelogram star pattern series // function for creating pattern function Pattern($rows, $cols) { for ($i = 1; $i <= $rows; $i++) { // Printing spaces for ($j = 1; $j < $i; $j++) { echo " "; } // Printing hollow parallelogram for ($j = 1; $j <= $cols; $j++) { if ($i == 1 || $i == $rows|| $j == 1 || $j == $cols) { echo "*"; } else { echo " "; } } echo "\n"; } } // Driver Code // Get number of rows and columns $rows = 5; $cols = 8; // Print the Pattern Pattern($rows, $cols); // This code is contributed by // Akanksha Rai ?> |
chevron_right
filter_none
Output:
********
* *
* *
* *
********
Recommended Posts:
- Program to print the hollow numerical parallelogram
- Program to print hollow Triangle pattern
- Program to print the pattern with two hollow Triangles
- Program to print solid and hollow rhombus patterns
- Program to print hollow pyramid and diamond pattern
- Program to print solid and hollow square patterns
- Program to print hollow rectangle or square star patterns
- C program to print a string without any quote (singe or double) in the program
- Hollow lower triangular pattern
- Program to print Hut
- Program to print pattern
- Program to print the pattern ‘D’
- Program to print the pattern 'G'
- Program to print DNA sequence
- Program to print 2D shapes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



