C Program to print Hollow Rhombus in a star pattern Type 2
Program
/* Hollow Rhombus */
#include<stdio.h>
void main()
{
int i, j, n;
printf("Enter the number of rows to print:\t");
scanf("%d", &n);
for(i = 1; i <= n; i++)
{
for(j = n; j > i; j--)
{
printf(" ");
}
printf("*");
for(j = 1; j < (i - 1) * 2; j++)
{
printf(" ");
}
if(i == 1)
printf("\n");
else
printf("*\n");
}
for(i = (n - 1); i >= 1; i--)
{
for(j = n; j > i; j--)
{
printf(" ");
}
printf("*");
for(j = 1; j < (i - 1) * 2; j++)
{
printf(" ");
}
if(i == 1)
printf("\n");
else
printf("*\n");
}
}
Output
Enter the number of rows to print: 6
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
*