/*
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;
}
/*
Summary: Print filled rhombus pattern of stars.
*/
#include <stdio.h>
int main()
{
int row, space, col, n;
printf("Enter the number of rows: ");
scanf("%d", &n);
for(row=1;row<=n;row++)
{
for(space=row;space<n;space++)
printf(" ");
for(col=1;col<(row*2);col++)
printf("*");
printf("\n");
}
for(row=n-1;row>=1;row--)
{
for(space=n;space>row;space--)
printf(" ");
for(col=1;col<(row*2);col++)
printf("*");
printf("\n");
}
return 0;
}
/*
Summary: Print rhombus pattern of stars.
*/
#include<stdio.h>
int main()
{
int row, col, n;
printf("Enter the number of rows: ");
scanf("%d", &n);
for(row=1; row<=n; row++)
{
for(col=n; col>row; col--)
printf(" ");
printf("*");
for(col=1; col<(row-1)*2; col++)
printf(" ");
if(row==1)
printf("\n");
else
printf("*\n");
}
for(row=n-1; row>=1; row--)
{
for(col=n; col>row; col--)
printf(" ");
printf("*");
for(col=1; col<(row-1)*2; col++)
printf(" ");
if(row==1)
printf("\n");
else
printf("*\n");
}
return 0;
}
/*
Summary: Print rectangle pattern of stars.
*/
#include<stdio.h>
int main()
{
int row, col, n, m;
printf("Enter the number of rows: ");
scanf("%d", &n);
printf("Enter the number of columns: ");
scanf("%d", &m);
for(row=1; row<=n; row++)
{
for(col=1; col<=m; col++)
{
if(row==1 || row==n || col==1 || col==m)
printf("* ");
else
printf(" ");
}
printf("\n");
}
return 0;
}
/*
Summary: Print square pattern of stars.
*/
#include<stdio.h>
int main()
{
int row, col, n;
printf("Enter the number of rows: ");
scanf("%d", &n);
for(row=1; row<=n; row++)
{
for(col=1; col<=n; col++)
{
if(row==1 || row==n || col==1 || col==n)
printf("* ");
else
printf(" ");
}
printf("\n");
}
return 0;
}
/*
Summary: Print reverse pyramid pattern of stars.
*/
#include<stdio.h>
int main()
{
int row, col, space, n;
printf("Enter the number of rows: ");
scanf("%d", &n);
for(row=n; row>=1; row--)
{
for(space=1; space<=n-row; space++)
printf(" ");
for(col=1; col<=row; col++)
printf("* ");
printf("\n");
}
return 0;
}
/*
Summary: Print pyramid 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(space=1; space<=n-row; space++)
printf(" ");
for(col=1; col<=row; col++)
printf("* ");
printf("\n");
}
return 0;
}
/*
Summary: Print stars in descending order from right to left.
*/
#include<stdio.h>
int main()
{
int row, col, space, n;
printf("Enter the number of rows: ");
scanf("%d", &n);
for(row=n; row>=1; row--)
{
for(space=1; space<=n-row; space++)
printf(" ");
for(col=1; col<=row; col++)
printf("* ");
printf("\n");
}
return 0;
}
/*
Summary: Print stars in ascending order from right to left.
*/
#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(space=1; space<=n-row; space++)
printf(" ");
for(col=1; col<=row; col++)
printf("* ");
printf("\n");
}
return 0;
}