Basic

Switch Case

Goto

Operators

if Statement

Nested if

While Loop

For Loop

Patterns

Array

2D Array

String Function Example

Pointers

Recursion Function

Structure

Excersises

Others


Print Square Pattern Using For Loop In C Program


Program to print square star pattern of n rows using for loop.

Example : pgm.c

#include<stdio.h>
int main(){
    int i,j,n;
	printf("\n Enter the limit:");
	scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            printf(" *");
        }
        printf("\n");
    }
}

Output:

Enter the limit:10
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *
	* * * * * * * * * *