Pattern 12: C Program to print Cross or X star pattern using loops

Spread the love

Write a C Program to print Cross or X star pattern:

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

Note: This is one the Series of pattern programs in C.

Program:

  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,j,n;
  5.     printf(“Enter any number : “);
  6.     scanf(“%d”,&n);
  7.  
  8.     for(i=0;i<n;i++)
  9.     {
  10.         for(j=0;j<n;j++)
  11.         {
  12.             if(i==|| j==(ni1))
  13.             {
  14.                 printf(” *”);
  15.             }
  16.             else
  17.             {
  18.                 printf(” “);
  19.             }
  20.         }
  21.         printf(n);
  22.     }
  23.     return 0;
  24. }

Output:

X-Star pattern program output on GCC

Similar Star pattern programs:

More C programs:

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

4 Responses

  1. foram says:

    How print
    a
    b
    c
    upto z

  2. foram says:

    How to print
    a
    b
    c
    d
    e…upto z

  3. Aman Rustagi says:

    Thanks nice programs for beginners. I found fer more pattern programs :

  1. March 8, 2017

    […] Example C code: Go to […]

Leave a Reply