C Program to Print Hollow Rhombus Star Pattern

Write a C Program to Print Hollow Rhombus Star Pattern using for loop. This C example uses nested for loops and if-else to print the Hollow Rhombus Pattern.

#include<stdio.h>
int main()
{
    int i, j, k, rows;
    printf("Enter Hollow Rhombus Star Pattern Rows =  ");
    scanf("%d", &rows);

    printf("Hollow Rhombus Star Pattern\n");
    for(i = rows; i >= 1; i--)
    {
        for(j = 1; j <= i - 1; j++)
        {
            printf(" ");
        }
        for(k = 1; k <= rows; k++)
        {
            if(i == 1 || i == rows || k == 1 || k == rows)
            {
                printf("*");
            }
            else
            {
                printf(" ");
            }       
        }         
        printf("\n");   
    }
    return 0;
}
C Program to Print Hollow Rhombus Star Pattern 1

This C Program allows entering symbols to Print in the Hollow Rhombus Pattern using while loop.

#include<stdio.h>
int main()
{
    int i, j, k, rows;
    char ch;
    
    printf("Symbol for Hollow Rhombus Pattern =  ");
    scanf("%c", &ch);

    printf("Enter Hollow Rhombus Star Pattern Rows =  ");
    scanf("%d", &rows);

    printf("Hollow Rhombus Star Pattern\n");
    i = rows;
    while(i >= 1)
    {
        j = 1;
        while( j <= i - 1)
        {
            printf(" ");
            j++;
        }
        k = 1;
        while( k <= rows)
        {
            if(i == 1 || i == rows || k == 1 || k == rows)
            {
                printf("%c", ch);
            }
            else
            {
                printf(" ");
            }  
            k++;     
        }         
        printf("\n"); 
        i--;  
    }
    return 0;
}
Symbol for Hollow Rhombus Pattern =  #
Enter Hollow Rhombus Star Pattern Rows =  9
Hollow Rhombus Star Pattern
        #########
       #       #
      #       #
     #       #
    #       #
   #       #
  #       #
 #       #
#########