C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C programs

C program for printing 'Square' pattern

In this article, we are implementing logic to print Square patter using asterisks and loops (nested loops).
Submitted by Shamikh Faraz, on February 16, 2018

In this program, we will learn, how we can print square using ‘asterisks’ and ‘loops’.

C program

#include <stdio.h>

int main()
	int a, b, n;

	printf("Enter number of rows: ");

	for(a=1; a<=n; ++a)
		for(b=1; b<=n; ++b)
			printf("* ");
	return 0;


Output - square pattern programs in C

Liked this article? Do share with your friends :)

Are you a blogger? Join our Blogging forum.