rectangular or square star and number pattern in C using for loop

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

Example

 

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;
}

When the above code is executed ,it produces the following result
Eample

C program to print the rectangular pattern using star. (get input method)

Program 3

#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

Example

C program to print the rectangular pattern Using star. (get input  row and column)

Program 4

#include <stdio.h>
#include <stdlib.h>
int main()
{
  int num1,num2, row, coloum;
  printf(“Enter Number of row to be display :n “);
  scanf(“%d”,&num1);
  printf(“Enter Number of coloum to be display :n “);
  scanf(“%d”,&num2);
  for(row=1; num1>=row; row++)
  {

 

      for(coloum=1; coloum<=num2; coloum++)
          {
          printf(“*”);
          }
      printf(“n”);
  }
  return 0;
}
When the above code is executed ,it produces the following result
Example
Karmehavannan

Recent Posts

Subtract two numbers using method overriding

Subtract two numbers using method overriding   Program 1

3 months ago

PHP Star triangle Pattern program

PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…

3 months ago

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

1 year ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

1 year ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

1 year ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

1 year ago

This website uses cookies.