C Program to Print Mirrored Half Diamond Star Pattern

Write a C Program to Print Mirrored Half Diamond Star Pattern using for loop. This C example uses the nested for loops to print the half diamond pattern. The first for loop set prints the upper portion of the diamond. The second for loop set prints the lower part of the diamond.

#include<stdio.h>
int main()
{
 	int i, j, rows; 
 	printf("Enter Mirrored Half Diamond Rows =  ");
 	scanf("%d", &rows);

    printf("Mirrored Half Diamond Star Pattern\n");
	for(i = 1; i <= rows; i++)
	{
		for(j = 1; j <= rows - i; j++)
		{
			printf(" ");
		}
        for(j = 1; j <= i; j++)
        {
            printf("*");
        }
		printf("\n");
	}

    for(i = rows - 1; i > 0; i--)
	{
		for(j = 1; j <= rows - i; j++)
		{
			printf(" ");
		}
        for(j = 1; j <= i; j++)
        {
            printf("*");
        }
		printf("\n");
	}
 	return 0;
}
C Program to Print Mirrored Half Diamond Star Pattern 1

In this C Program, we used the while loop to Print Mirrored Half Diamond Star Pattern. It also allows entering the Mirrored Half Diamond pattern symbol.

#include<stdio.h>
int main()
{
 	int i, j, rows; 
	char ch;
    
    printf("Symbol to Print Mirrored Half Diamond =  ");
    scanf("%c", & ch);

 	printf("Enter Mirrored Half Diamond Rows =  ");
 	scanf("%d", &rows);

    printf("Mirrored Half Diamond Star Pattern\n");
	i = 1;
	while( i <= rows)
	{
		j = 1;
		while(j <= rows - i)
		{
			printf(" ");
			j++;
		}
		j = 1;
        while(j <= i)
        {
            printf("%c", ch);
			j++;
        }
		printf("\n");
		i++;
	}

	i = rows - 1;
    while( i > 0)
	{
		j = 1;
		while(j <= rows - i)
		{
			printf(" ");
			j++;
		}
		j = 1;
        while(j <= i)
        {
            printf("%c", ch);
			j++;
        }
		printf("\n");
		i--;
	}

 	return 0;
}
Symbol to Print Mirrored Half Diamond =  #
Enter Mirrored Half Diamond Rows =  6
Mirrored Half Diamond Star Pattern
     #
    ##
   ###
  ####
 #####
######
 #####
  ####
   ###
    ##
     #