Code Box
---------------------------------------
/* Program to print diamond pattern 10 */
#include <stdio.h>
#include <conio.h>
void main()
{
int i, j, k,n;
clrscr();
printf("Enter the number of stars: ");
scanf("%d",&n);
printf("\n---------------Diamond pattern-------------------\n");
for (i = 1; i <= n; i++)
{
for (j = 0; j < (n - i); j++)
printf(" ");
for (j = 1; j <= i; j++)
printf(" ");
for (k = 1; k <=i; k++)
printf("*");
printf("\n");
}
for (i = n; i >= 1; i--)
{
for (j = 0; j < (n - i); j++)
printf(" ");
for (j = 1; j <= i; j++)
printf("*");
for (k = 1; k < i; k++)
printf(" ");
printf("\n");
}
printf("\n");
printf("\n----------------------------------\n");
getch();
}
No comments:
Post a Comment