Mirrored Rhombus Star Pattern

Program to Print Mirrored Rhombus Star Pattern

PRINTING PATTERN:

   ****
  ****
 ****
****
            

PREREQUISITE:

Basic knowledge of C language and loops.

ALGORITHM:

1. Take the number of rows as input from the user (height of the mirrored rhombus) and store it in a variable ('n').
2. Run a loop 'n' times to iterate through the rows (i=0 to i<n).
3. For each row, print spaces to create the left alignment of the stars.
4. Print stars for each row.
5. Move to the next line after each row has been printed.

Code in C:

#include <stdio.h>

int main() {
    int n, i, j;  // Declaring integers for rows and loop counters
    printf("Enter the number of rows for the mirrored rhombus:\n");
    scanf("%d", &n);  // Taking input for number of rows

    for (i = 0; i < n; i++) {
        // Print spaces for mirrored rhombus shape
        for (j = n - i; j > 1; j--) {
            printf(" ");  // Printing spaces
        }
        // Print stars for each row
        for (j = 0; j < 4; j++) {  // Assuming the width of the rhombus is 4
            printf("*");  // Printing stars
        }
        printf("\n");  // New line after each row
    }

    return 0;
}
            

Output:

Enter the number of rows for the mirrored rhombus:
4
   ****
  ****
 ****
****