Posted by : Unknown
Wednesday, February 3, 2016
Ans:
#include <stdio.h>
int main()
{
int i, j, n;
//Reads the number of rows from user
printf("Enter number of rows : ");
scanf("%d", &n);
//Iterates over each row of pattern
for(i=1; i<=n; i++)
{
//Prints trailing spaces
for(j=i; j<n; j++)
{
printf(" ");
}
//Prints the rhombus pattern
for(j=1; j<=n; j++)
{
if(i==1 || j==1 || i==n || j==n)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Related Posts :
- Back to Home »
- Star Patterns »
- 36.Hollow Rhombus using *'s as shown below.