How to print Hollow Mirrored Rhombus pattern with C ?

#include <stdio.h>
int main()
{
    int i, j, n;
    printf("Enter number of rows : ");
    scanf("%d", &n);
    for(i=1; i<=n; i++)
    {
        //Prints trailing spaces
        for(j=1; j<i; j++)
        {
            printf(" ");
        }
        for(j=1; j<=n; j++)
        {
            if(i==1 || j==1 || i==n || j==n)
            {
                printf("*");
            }
            else
            {
                printf(" ");
            }
        }
        printf("n");
    }
    return 0;
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu