Signup/Sign In

Print Square Star Pattern Program In C Language

Learn C language tutorial

Logic To Print Square Star Pattern Program:

  • Get the value from the user to print the square star pattern
  • To print the square star pattern for loop is used,
  • Use an inner loop and outer loop to print square pattern,
  • The inner loop is used to print the character, and the outer loop is used to print the rows.

C Program To Print The Square Star Pattern:

#include<stdio.h>
int main()
{
    int x = 0,y = 0;
    unsigned int squareSide = 0;
    printf("Enter The Value To Print The Square Star Pattern = ");
    scanf("%u",&squareSide);
    
    for(x = 0; x < squareSide; ++x)
    {
    
        for(y = 0; y < squareSide; ++y)
        {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

Output:

Square Star