ADVERTISEMENT
ADVERTISEMENT

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: ");
	scanf("%d",&n);

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

Output

Output - square pattern programs in C

ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.