Generate Cross Pattern Using Star in C

Generating CROSS like pattern of star using C programming language.


#include<stdio.h>

int main()
{
    int i, j, n;

    printf("Enter n: ");
    scanf("%d", &n);

    /* Pattern */
    for(i=1;i<=2*n-1;i++)
    {
        for(j=1;j<=2*n-1;j++)
        {
            if(i==j||i+j==2*n)
            {
                printf("*");
            }
            else
            {
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}

Output of above program

Enter n: 10

*                 *
 *               *
  *             *
   *           *
    *         *
     *       *
      *     *
       *   *
        * *
         *
        * *
       *   *
      *     *
     *       *
    *         *
   *           *
  *             *
 *               *
*                 *