Home C Programming Language / Programs / C program to print hollow rhombus, parallelogram star pattern ***** * * * * * * *****
🚀 Programming Example

C program to print hollow rhombus, parallelogram star pattern
    *****
   *   *
  *   *
 *   *
*****

👁 1,485 Views
💻 Practical Program
📘 Step Learning
Write a C program to print hollow rhombus star series pattern using for loop. How to print hollow rhombus or parallelogram star pattern in C programming. Logic to print empty rhombus or parallelogram star pattern series in C programming.

💻 Program Code

/**
 * C program to print hollow rhombus star pattern
* atnyla.com
 */

#include <stdio.h>

int main()
{
    int i, j, rows;

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


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


        /* Print stars and center spaces */
        for(j=1; j<=rows; j++)
        {
            if(i==1 || i==rows || j==1 || j==rows)
                printf("*");
            else
                printf(" ");
        }

        printf("\n");
    }

    return 0;
}
Output
                        

🖥 Program Output

Enter rows: 5
    *****
   *   *
  *   *
 *   *
*****
                            

📘 Explanation

Logic to print hollow rhombus star pattern

 

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

 

Step by step descriptive logic to print rhombus star pattern.

  1. Input number of rows to print from user. Store it in a variable say rows.
  2. To iterate through rows, run an outer loop from 1 to rows. Define an outer loop with structure for(i=1; i<=rows; i++).
  3. To print trailing spaces, run an inner loop from 1 to rows - i. Run a loop with structure for(j=1; j<=rows - i; j++). Inside this loop print blank space.
  4. To print stars, run another inner loop from 1 to rows with structure for(j=1; j<=rows; j++).
  5. Inside this loop print star for first or last row, and for first or last column otherwise print spaces. Which is print stars only when i==1 or i==rows or j==1 or j==rows.
  6. After printing all columns of a row move to next line i.e. print new line.
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.