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