Table of Contents
rectangular or square star and number pattern in C using for loop
In this article, we will discuss the rectangular or square star and number pattern in C using for loop
In the C Language, We can print various type of Rectangular shapes through nested for loop using number and special character
C program to print the rectangular shape using star
Examples
Program 1
#include <stdio.h>
#include <stdlib.h>
int main()
{
int row;
int coloum;
for(row=1; row<=10; row++){
for(coloum=1; coloum<=10; coloum++){
printf(“*”);
}
printf(“n”);
}
return 0;
}
When the above code is executed ,it produces the following result
C program to print the rectangular shape using numbers
program 2
#include <stdio.h>
#include <stdlib.h>
int main()
{
int row;
int coloum;
for(row=1; row<=10; row++){
for(coloum=1; coloum<=10; coloum++){
printf(“%d”,coloum);
}
printf(“n”);
}
return 0;
}
C program to print the rectangular pattern using star. (get input method)
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num, row, coloum;
printf(“Enter Number of row to be disply :n “);
scanf(“%d”,&num);
for(row=1; num>=row; row++)
{
for(coloum=1; coloum<=num; coloum++)
{
printf(“*”);
}
printf(“n”);
}
return 0;
}
When the above code is executed ,it produces the following result
C program to print the rectangular pattern Using star. (get input row and column)
Program 4