Write a program to print below
pattern.
Note: Get INPUT using
command line
Sample Input and output:
Input:
5
Output:
**********
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
**********
Solution:
#include
<stdio.h>
int
main(int argc, char *argv[])
{
int i, j, k;
int n=atoi(argv[1]);
for(i=1;i<=n;i++)
{
for(j=1;j<=n+1-i;j++)
{
printf("*");
}
for(k=1;k<i;k++)
{
printf(" ");
}
for(j=1;j<=n+1-i;j++)
{
printf("*");
}
printf("\n");
}
for(i=2;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=1;k<=n-i;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}