Print Star Pattern C Program – Part 1

By | October 9, 2016

Learn How To Print Star Pattern Program in C Programming Language. This pattern code makes use of For Loop and While Loop. It displays a plus sign using Star Patterns.

Must Read: C Program To Print Right Angled Triangle using Star Pattern

C Program To Display Star Pattern using For Loop

#include<stdio.h>

int main()
{
      int m, n;
      for(m = 0; m < 11; ++m)
      {
            for(n = 0; n < 11; ++n)
            {
                  if(n != 5 && m != 5)
                  {
                        printf(" "); 
                  }
                  else 
                  {
                        printf ("*");
                  }
            }
            printf("\n");
      }
      return 0;
}

C Program To Print Pattern of Stars using While Loop

#include<stdio.h>

int main()
{
      int m = 0, n;
      while(m < 11)
      {
            n = 0;
            while(n < 11)
            {
                  if(n != 5 && m != 5)
                  {
                        printf(" "); 
                  }
                  else 
                  {
                        printf ("*");
                  }
                  n++;
            }
            printf("\n");
            m++;
      }
      return 0;
}

Output

C Program To Print Star Pattern Program using While and For Loop

If you have any compilation error or doubts in this C code to Print Star Pattern Program, let us know about it in the comment section below.

Let's Discuss