Star Rhombus (Hollow)

By Developgram - January 10, 2017

/*
Summary: Print hollow rhombus pattern of stars.
*/

#include <stdio.h>

int main()
{
    int row, col, space, n;
    
    printf("Enter the number of rows: ");
    scanf("%d", &n);
    
    for(row=1;row<=n;row++)
    {
        for(col=1;col<=(n+1)-row;col++)
            printf("*");
            
        for(space=1;space<row;space++)
            printf("  ");
            
        for(col=1;col<=(n+1)-row;col++)
            printf("*");
        printf("\n");
    }
    
    for(row=2;row<=n;row++)
    {
        for(col=1;col<=row;col++)
            printf("*");
            
        for(space=1;space<=n-row;space++)
            printf("  ");
            
        for(col=1;col<=row;col++)
            printf("*");
        printf("\n");
    }

    return 0;
} 

  • Share:

You Might Also Like

0 comments