Follow This Blog For more... 😊

C Program to print Hollow Square Pattern for n number of lines.[Pattern 23]| Using C language| C Program series 44|

👨‍💻C Program to 
print Hollow Square for n number of lines.[Pattern:23]

Code :

For n number of LINES:

    /*
    C Program to print Hollow Square Pattern for n number of lines.[Pattern 23]
    For Example:n=5
   
   
    # # # # #
    #       #
    #       #
    #       #
    # # # # #
   
    */
   
    #include<stdio.h>
    main()
    {
        printf("C Program to print Hollow Square Pattern for n number of lines.[Pattern 23]\n\n");
       
        int i,j,n;
       
        printf("Enter the number of lines:");
        scanf("%d",&n);
        printf("==> Hollow Square Patter.\n");
        for(i=1;i<=n;i++)
        {
            printf("\n\t");//here, '\t' used to shift pattern 1 tab space right side
            for(j=1;j<=n;j++)
            {
                if(i==1||i==n||j==1||j==n)
                {
                    printf("# ");
                }
                else
                {
                    printf("  ");
                }
            }
        }
        printf("\n");
    }

The output of Code:




👉Click for more C Program series Questions.[Questions list]

Comments

Popular Posts