#include<stdio.h>
int main()
{
int a,b,c,i,j,k,n;
printf("Enter the (half)size of dimond:\n");
scanf("%d",&n);
//for first half of diamond
for(a=n;a>0;a--)
{
for(b=1;b<a;b++)
{
printf(" ");
}
for(c=b-1;c<n;c++)
{
printf("*");
printf(" ");
}
printf("\n");
}
//for second half of diamond
for(i=n-1;i>=0;i--)
{
for(j=n;j>i;j--)
{
printf(" ");
}
for(k=0;k<i;k++)
{
printf("*");
printf(" ");
}
printf("\n");
}
return 0;
}
int main()
{
int a,b,c,i,j,k,n;
printf("Enter the (half)size of dimond:\n");
scanf("%d",&n);
//for first half of diamond
for(a=n;a>0;a--)
{
for(b=1;b<a;b++)
{
printf(" ");
}
for(c=b-1;c<n;c++)
{
printf("*");
printf(" ");
}
printf("\n");
}
//for second half of diamond
for(i=n-1;i>=0;i--)
{
for(j=n;j>i;j--)
{
printf(" ");
}
for(k=0;k<i;k++)
{
printf("*");
printf(" ");
}
printf("\n");
}
return 0;
}
Comments
Post a Comment