Pattern Program in C Programming Language (post - 2) | YourSite

Pattern Program in C Programming Language (post - 2)

To Read our first post about parttern programming  

Program15:

#include<stdio.h>
void main()
{
    int i, j;
    for(i=5 ; i>=1 ; i--)
    {
        for(j=1 ; j<=i ; j++)
        {
            printf("%d ", j);
        }
        printf("\n");
    }
}

Output:

1 2 3 4 5
1 2 3 4
1 2 3
1 2
1 

Program16:

#include<stdio.h>
void main()
{
    int i, j, k;
    for(i=1 ; i<=5 ; i++)
    {
        for(j=1 ; j<i ; j++)
        {
            printf("  ");
        }
        for(k=i ; k<=5 ; k++)
        {
            printf("* ");
        }
        printf("\n");
    }
}

Output:

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

Program17:

#include<stdio.h>
void main()
{
    int i, j, k;
    for(i=1 ; i<=5 ; i++)
    {
        for(j=i ; j<5 ; j++)
        {
            printf("  ");
        }
        for(k=1 ; k<=i ; k++)
        {
            printf("* ");
        }
        printf("\n");
    }
}

Output:

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

Program18:

#include<stdio.h>
void main()
{
    int i, j, n, k=0;
    printf("Enter row number : ");
    scanf("%d", &n);
    for(i=1 ; i<=n ; i++)
    {
        for(j=1 ; j<=i ; j++)
        {
            printf("%d ",k++%10);
        }
        printf("\n");
    }
}

Output:

Enter row number : 5
0
1 2
3 4 5
6 7 8 9
0 1 2 3 4 

Program19:

#include<stdio.h>
void main()
{
    int i, j, n, k=0;
    printf("Enter row number : ");
    scanf("%d", &n);
    for(i=1 ; i<=n ; i++)
    {
        for(j=1 ; j<=i ; j++)
        {
            printf("%d ",k++%2);
        }
        printf("\n");
    }
}

Output:

Enter row number : 5
0
1 0
1 0 1
0 1 0 1
0 1 0 1 0 

Program20:

#include<stdio.h>
void main()
{
    int i, j, k, c=10;
    for(i=1 ; i<=5 ; i++)
    {
        for(j=1 ; j<=c/2-i ; j++)
        {
            printf("  ");
        }
        for(k=1 ; k<=2*i-1 ; k++)
        {
            printf(" %d", k);
        }
        printf("\n");
    }
}

Output:

         1
       1 2 3
     1 2 3 4 5
   1 2 3 4 5 6 7
 1 2 3 4 5 6 7 8 9 

Program21:

#include<stdio.h>
void main()
{
    int i, j;
    for(i=1; i<=5 ; i++)
    {
        for(j=1 ; j<=i ; j++)
        {
            printf("%c ", 64+i);
        }
        printf("\n");
    }
}

Output:

A
B B
C C C
D D D D
E E E E E 

Program22:

#include<stdio.h>
void main()
{
    int i, j, k;
    for(i=1; i<=5; i++)
    {
        for(j=1; j<i ; j++)
        {
            printf("  ");
        }
        for(k=10 ; k>2*i-1; k--)
        { 
            printf("* ");
        }
        printf("\n");
    }
}

Output:

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

Program23:

#include<stdio.h>
int main()
{
  int i,j,k;
  for(i=5 ; i>1 ; i--)
  {
    for(j=1 ; j<5 ; j++)
    {
      if(j<i)
        printf("%d ",j);
      else
        printf("* ");
    }
    for(j=5 ; j>=1 ; j--)
    {
      if(j<i)
        printf("%d ",j);
      else
        printf("* ");
    } 
    printf("\n");
  }
  return 0;
}

Output:

1 2 3 4 * 4 3 2 1
1 2 3 * * * 3 2 1
1 2 * * * * * 2 1
1 * * * * * * * 1 

Program24:

#include<stdio.h>
void main()
{
    int i, j;
    for(i=1 ; i<=5 ; i++)
    {
        for(j=i ; j<=5 ; j++)
        {
            if(i==1 || j==i || j==5)
            {
                printf("* ");
            }
            else
            {
                printf("  ");
            }
        }
        printf("\n");
    }
} 

Output25:

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

Program26:

#include<stdio.h>
void main()
{
    int i, j;
    for(i=1 ; i<=5 ; i++)
    {
        for(j=1 ; j<=i ; j++)
        {
            printf("%d ", j);
        }
        for(j=i*2 ; j<10 ; j++)
        {
            printf("  ");
        }
        for(j=i ; j>=1 ; j--)
        {
            printf("%d ", j);
        }
        printf("\n");
    }
}

Output:

1                 1
1 2             2 1
1 2 3         3 2 1
1 2 3 4     4 3 2 1
1 2 3 4 5 5 4 3 2 1 

Program27:

#include<stdio.h>
void main()
{
    int i, j;
    for(i=1 ; i<=5 ; i++)
    {
      for(j=5 ; j>i ; j--)
        printf("  ");
      for(j=1 ; j<=i ; j++)
          printf("%d ",j);
      for(j=j-2 ; j>=1 ; j--)
          printf("%d ",j);
      printf("\n");
    }
}

Output:

        1
      1 2 1
    1 2 3 2 1
  1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1 

Program28:

#include<stdio.h>
void main()
{
    int x,y;
    char str[]="INDIA";
     for(x=0 ; x<5 ; x++)
     {
            y=x+1;
            printf("%-5.*s\n",y,str);
     }
     for(x=4; x>=0; x--)
     {
            y=x+1;
            printf("%-5.*s\n",y,str);
     }
}

Output:

I
IN
IND
INDI
INDIA
INDIA
INDI
IND
IN
I 
Read out first post about parttern programming

🚀 More Blogs You Might Like

Explore more articles and keep learning

What is Bounce Rate in SEO? Complete Guide for Beginners
search-engine-optimization
What is Bounce Rate in SEO? Complete Guide for Beginners

Learn what bounce rate is in SEO, how it is calculated, why it matters, common causes of high bounce rates, an...

👁 28 2026-05-24
Read More →
Comprehensive Interviewer Guide - Detailed Article
skill
Comprehensive Interviewer Guide - Detailed Article

Learn how to conduct effective interviews with this comprehensive interviewer guide. Explore hiring strategies...

👁 43 2026-05-22
Read More →
Five Industry Shifts Reshaping the AI Ecosystem (2026 Trends)
skill
Five Industry Shifts Reshaping the AI Ecosystem (2026 Trends)

Five Industry Shifts Reshaping the AI Ecosystem (2026 Trends)...

👁 38 2026-05-19
Read More →
How to Grow Your Business Mindset Step by Step
skill
How to Grow Your Business Mindset Step by Step

Learn how to develop and grow a successful business mindset step by step. Discover entrepreneurial thinking, p...

👁 56 2026-05-09
Read More →