*****
* *
* *
* *
*****
/**
* C program to print hollow mirrored rhombus star pattern series
* atnyla.com
*/
#include <stdio.h>
int main()
{
int i, j, N;
/* Input number of rows from user */
printf("Enter number of rows: ");
scanf("%d", &N);
for(i=1; i<=N; i++)
{
/* Print trailing spaces */
for(j=1; j<i; j++)
{
printf(" ");
}
/* Print hollow rhombus */
for(j=1; j<=N; j++)
{
if(i==1 || i==N || j==1|| j==N)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
Enter the value of n: 5
*****
* *
* *
* *
*****
Basic C programming, If else, For loop, Nested loop
*****
* *
* *
* *
*****
Read more - Program to print hollow rhombus star pattern.
The above pattern contains N rows and columns (where N is total rows to print). If you can notice there are exactly i - 1 spaces each row (where i is current row number). To see or count trailing spaces per row you can hover or click on to the above pattern. Also the stars are printed only for first or last row or for first or last column otherwise blank space is printed.
Step by step descriptive logic to print hollow mirrored rhombus star pattern.
for(i=1; i<=N; i++).i - 1 with loop structure for(j=1; j. Inside this loop print single blank space.for(j=1; j<=N; j++). Inside this loop print stars only if i==1 or i==N or j==1 or j==N.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.
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.