Write a C program to draw X Star Pattern

Here is code X Star Pattern in C

#include <stdio.h>  
  
int main(void) {  
  int n,m;  
  printf("Enter the number");  
  scanf("%d",&n);  
  m=2*n-1;  
  for(int i=1;i<=m;i++)  
  {  
    for(int j=1;j<=m;j++)  
    {  
       if(i==j || j==(m-i+1))  
       {  
         printf("*");  
       }  
       else  
       {  
         printf(" ");  
       }  
    }  
    printf("\n");  
  }  
  return 0;  
}  

Output:

Write a C program to draw X Star Pattern

If You Enjoyed This, Take 5 Seconds To Share It

You May Also Like

About the Author: Ajab Noor

Leave a Reply

Your email address will not be published. Required fields are marked *