Pattern 18: hollow square Star pattern program in C using for loops

Spread the love

Write a C program to print the following Hollow Square Star pattern using for loops:

Note: This program is one of the program in Series of Star Pattern programs in C

Program :

  1. #include<stdio.h>
  2. int main()
  3. {
  4.    int i,j,k,n;
  5.    printf(“Enter Number : “);
  6.    scanf(“%d”,&n);
  7.    for(i=1;i<=n;i++)
  8.    {
  9.        for(j=1;j<=n;j++)
  10.        {
  11.            if(i==1||i==n||j==1||j==n)
  12.                printf(“* “);  // one Star, one Space
  13.            else
  14.                printf(”  “);  // two Spaces
  15.        }
  16.        printf(n);
  17.     }
  18.     return 0;
  19. }

Output of Hollow Square star pattern program on GNU GCC: 

Related Programs :

More C programs:

C Tutorials with simple Examples:

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...

Leave a Reply