C program to print Hollow Rhombus Star Pattern
A rhombus is a quadrilateral, which is a two-dimensional figure having four sides joined together. The opposite sides of a rhombus are parallel to one other, which is one of its properties.
In nature, all of the sides of a rhombus are equal. In nature, the opposite angles of a rhombus are also equal. The diagonals of a rhombus also cut each other at right angles as a result of these properties.
Algorithm For Hollow Rhombus:
- Get the input from the user for the number of rows in the hollow rhombus.
- Based on the input print the first row contains the number of stars or symbols.
- Only the First and Last star should be printed and leave the spaces between the first and last star
- Continue the same until you reach the final row.
- Just like step 2 print the number of stars based on the given number of rows.
Logic To Print The Hollow Rhombus:
- Get the input from the user to print a number of rows, and store it in a variable.
- Define the outer loop using structure for(i= 2; I<=rows; i++)
- To print the spaces, the inner loop should be created from 1 to rows -i.
- Define the inner loop using structure for(j= 1; j<=rows -i; j++).
- To print the stars another loop should be created from 1 to rows.
- Define the another loop using structure for(j= 1; j<=rows; j++).
- Print the star in the first and last row, leaving spaces between the stars.
- Stars should be printed only when the condition meets i==1; or i == rows;
- After printing stars in rows and columns, print a new line.
C Program To Print The Hollow Rhombus:
printf("Enter The Number Of Rows To Print The Hollow Rhombus Pattern: ");
printf("Enter The Symbol To Represent Hollow Rhombus: ");
if(i==1 || i==n)
if(j==1 || j==n)