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

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.