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