Home » C programs

C program for printing 'Rectangle' Pattern



In this C program, we are going to learn how to design a rectangle type of pattern using asterisk and loops (nested loops)?
Submitted by Shamikh Faraz, on February 16, 2018

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

C program

#include <stdio.h>

int main()
{
	int a, b, columns,rows;

	printf("Enter number of rows: ");
	scanf("%d",&rows);

	printf("Enter number of columns: ");
	scanf("%d",&columns);

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

Output

Output - pattern of starts






Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.




Comments and Discussions





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 (2015-2018), Some rights reserved.