This is a C Program which prints out the diamond with stars pattern.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglAk6rxOd3mO43URBsyS7sm2B4frtboPph_-3wKd86HS8Zg2FVhpgcHg6GTxqA3CQlYiQpWXGPjmLBiOdr2PqILM5bHzkce0T0ncp-x9K908BbcKYAdyzlGpP8tndfQ7jhV0Xa3RVTbXk/s1600/diamondwithstarsS.PNG) |
Diamond with stars (pattern) |
PROGRAM :
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, j, k,n;
printf("Enter number of lines[height of diamond] : \t");
scanf("%d",&n);
for(i=1; i<=n; i++)
{
for(j=i; j<n; j++)
{
printf(" ");
}
for(k=1; k<(i*2); k++)
{
printf("*");
}
printf("\n");
}
for(i=n-1; i>=1; i--)
{
for(j=n; j>i; j--)
{
printf(" ");
}
for(k=1; k<(i*2); k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
OUTPUT :
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmj9A6Bfz5Z7eJM2m4v5hvPAInlGE0_wcsrfFdYoPyXNjFHzhtqjbnlYyX8rW_KdWjmiUEYfuka3Kft1jm1M_vrz7h2_0_XqfvtWILi2obF95uAR7MG8D5m46qWcJTK_wVCyKMYdWr9pc/s1600/diamondwithstars.PNG) |
C Program to print diamond. |
No comments:
Post a Comment