Mirrored Rhombus star pattern || Pattern || C programming


In this, we are going to see a program in which we will be printing a Mirrored Rhombus Star pattern as shown in above image in C Programming Language.

/*Star pattern - (Mirrored Rhombus star pattern)
   * * * * *
     * * * * *
       * * * * *
         * * * * *
           * * * * *  
*/

#include <stdio.h>

int main()
{
    int n;

    printf("Enter no. of rows/columns: ");
    scanf("%d", &n);

    int x = 0, y = 0;

    for (x = 1; x <= n; ++x)
    {
        // Print spaces
        for (y = 1; y <= x; y++)
        {
            if (y != 1)
            {
                printf("  ");
            }
        }

        // Print stars
        for (y = 1; y <= n; ++y)
        {
            if (y != 1)
            {
                printf(" ");
            }
            printf("*");
        }
        printf("\n");
    }
    
    return 0;
}

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post