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

Pattern Program in C Programming Language (post - 1)

This blog is our first blog for Pattern Programs. If you want to know more about * Pattern Programs also read from below link.

Read out second post about parttern programming

Program1:


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

Output:

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

Program2:


/**
 * C program to print square star pattern
 */

#include<stdio.h>

int main()
{
    int i, j, N;

    // Input number of rows from user
    printf("Enter number of rows: ");
    scanf("%d", &N);

    // Iterate over rows
    for(i=1; i<=N; i++)
    {
        // Iterate over columns
        for(j=1; j<=N; j++)
        {
            // Print star for each column
            printf("*");
        }
        
        // Move to the next line/row
        printf("\n");
    }

    return 0;
}

Output:

Enter number of rows: 6
******
******
******
******
******
****** 

Program3:


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

Output:

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

Program4:


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

Output:

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

Program5:


#include<stdio.h>
void main()
{
    int i;
    for(i=1 ; i<=25 ; i++)
    {
        printf("* ");
        if(i%5==0)
            printf("\n");
    }
}

Output:

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

Program6:


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

Output:

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

Program7:


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

Output:

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

Program8:


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

Output:

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

Program9:


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

Output:

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

Program10:


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

Output:

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

Program11:


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

Output:

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

Program12:


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

Output:

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

Program13:


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

Output:

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

Program14:


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

Output:

5 4 3 2 1
4 3 2 1
3 2 1
2 1
1 
Read out second 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 →