#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 the first half of diamond
for(i=n;i>0;i--)
{
for(j=1;j<i;j++)
{
printf(" ");
}
for(k=j-1;k<n;k++)
{
printf("*");
printf(" ");
}
printf("\n");
}
//for the second half of diamond
for(a=n-1;a>=0;a--)
{
for(b=n;b>a;b--)
{
printf(" ");
}
for(c=0;c<a;c++)
{
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 the first half of diamond
for(i=n;i>0;i--)
{
for(j=1;j<i;j++)
{
printf(" ");
}
for(k=j-1;k<n;k++)
{
printf("*");
printf(" ");
}
printf("\n");
}
//for the second half of diamond
for(a=n-1;a>=0;a--)
{
for(b=n;b>a;b--)
{
printf(" ");
}
for(c=0;c<a;c++)
{
printf("*");
printf(" ");
}
printf("\n");
}
return 0;
}
No comments:
Post a Comment