Simple Pattern program in C

Spread the love
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 star pattern. It is a straightforward program with two for loops and one loop is responsible for rows logic and another loop is responsible for columns logic. 

Q: Write a C Program to print below pattern.

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

Program :

  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 Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply