Simple Pattern program in C

Simple Pattern Program in C:

I just want to start one new series of pattern programs. So as a first program in this series, let’s start with the basic or simple pattern program. It is a Rectangular Start pattern Program.
It is a straightforward program with two for loops and The outer for loop is responsible for rows logic and The inner for loop is responsible for columns logic.
So if user provides the input as 5. The outer for loop will start from 1 and goes upto the number 5. Similarly the Inner for loop starts with 1 and goes till the number 5. At each Outer loop iteration, The inner for loop will iterate given number times ( i.e 5).

Q: Write a C Program to print below simple star pattern.

 
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

Simple Pattern Program [ Rectangular Star Pattern] :

  1. #include<stdio.h>
  2. int main()
  3. {
  4.         int i,j,k;
  5.         printf(“Enter how many rows you want: “);
  6.         scanf(“%d”,&n);
  7.         // for loop with control variable i is to control the Rows.
  8.         // for loop with control variable j is to control the Columns. 
  9.         for(i=1;i<=n;i++)
  10.         {
  11.                 for(j=1;j<=n;j++)
  12.                         printf(” *”);
  13.                
  14.                 printf(n);
  15.         }
  16.         return 0;
  17. }

Output :

Also See:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

2 Responses

  1. codeforhunger says:

    Nice blog, keep sharing all type of program…

  1. […] Pattern 1: Rectangular Star Pattern Program […]

Leave a Reply