Home / Programs / Program to print hollow mirrored parallelogram star pattern ********* * * * * * * * * *********
Programming Example

Program to print hollow mirrored parallelogram star pattern
*********
 *       *
  *       *
   *       *
    *       *
     *********

👁 1,575 Views
💻 Practical Program
📘 Step by Step Learning
Logic to print above pattern is same as hollow mirrored rhombus star pattern. The only thing we need to change here is, we need to iterate through M rows and N columns (where M is total rows to print and Nis total columns to print).

Program Code

/**
 * C program to print hollow mirrored parallelogram star pattern series
* atnyla.com
 */

#include <stdio.h>

int main()
{
    int i, j, M, N;

    /* Input number of rows from user */
    printf("Enter rows: ");
    scanf("%d", &M);
    printf("Enter columns: ");
    scanf("%d", &N);

    for(i=1; i<=M; i++)
    {
        /* Print trailing spaces */
        for(j=1; j<i; j++)
        {
            printf(" ");
        }


        /* Print hollow parallelogram */
        for(j=1; j<=N; j++)
        {
            if(i==1 || i==M  || j==1|| j==N)
                printf("*");
            else
                printf(" ");
        }

        printf("\n");
    }

    return 0;
}

Output

Enter rows: 6
Enter columns: 9
*********
 *       *
  *       *
   *       *
    *       *
     *********
Press any key to continue . . .

Explanation

Logic to print hollow mirrored parallelogram star pattern

 

********************
 *                  *
  *                  *
   *                  *
    ********************

 

Logic to print above pattern is same as hollow mirrored rhombus star pattern. The only thing we need to change here is, we need to iterate through M rows and N columns (where M is total rows to print and Nis total columns to print).

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.