Write a C program to draw Plus Star Pattern

Here is code Plus Star Pattern in C

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

Output:

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

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 *