LAST UPDATED: JANUARY 10, 2022
C Program To Print Mirrored Rhombus Star Pattern
A Rhombus is a quadrilateral with equal-length sides that is bound in nature. A rhombus's opposite sides are parallel to one other. In nature, the opposite angles of a rhombus are also equal. The diagonals of a rhombus meet at right angles as a result of all of these properties.
Here, In this program, a rhombus is printed in a star pattern using the C language with the help of looping,
Algorithm to print the Rhombus Star Pattern:
- Get the input from the user and store the value in a Variable "x"
- Run an outer loop from 1to x increment the value of x by 1 in each iteration.
- An inner loop should be used to print the spaces, Inside the loop print the spaces
- Another loop should be used to print the * until x, Print stars inside the loop
- Move to the new line after printing stars in all columns
It can be implemented using For Loop, While Loop and Do While Loop, Here the program is executed using the For Loop.
C Language Program To Print Mirrored Rhombus Star Pattern:
#include <stdio.h>
int main()
{
int i, j, x;
printf("Enter The No. Of rows To Print Rhombus: ");
scanf("%d", &x);
for(i=1; i<=x; i++)
{
/* Code Block To Print spaces */
for(j=1; j<i; j++)
{
printf(" ");
}
for(j=1; j<=x; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Output: