Posted by : Unknown
Thursday, February 4, 2016
Ans:
#include <stdio.h>
int main()
{
int i, j, n;
printf("Enter value of n : ");
scanf("%d", &n);
for(i=n/2; i<=n; i+=2)
{
for(j=1; j<n-i; j+=2)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
for(j=1; j<=n-i; j++)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n");
}
for(i=n; i>=1; i--)
{
for(j=i; j<n; j++)
{
printf(" ");
}
for(j=1; j<=(i*2)-1; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
int main()
{
int i, j, n;
printf("Enter value of n : ");
scanf("%d", &n);
for(i=n/2; i<=n; i+=2)
{
for(j=1; j<n-i; j+=2)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
for(j=1; j<=n-i; j++)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n");
}
for(i=n; i>=1; i--)
{
for(j=i; j<n; j++)
{
printf(" ");
}
for(j=1; j<=(i*2)-1; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Related Posts :
- Back to Home »
- Star Patterns »
- 50. Heart Shape using *'s as shown below.