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

Pattern Program in C Programming Language (post - 1)

C Programming Language • 3011 views

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

Heat Stroke in Summer: Causes, Symptoms, Prevention and What To Do
health
Heat Stroke in Summer: Causes, Symptoms, Prevention and What To Do

Heat Stroke in Summer: Causes, Symptoms, Prevention and What To Do...

👁 8 2026-04-26
Read More →
Alcoholic Fatty Liver Disease: Causes, Symptoms, Risks and How to Improve It
health
Alcoholic Fatty Liver Disease: Causes, Symptoms, Risks and How to Improve It

Alcoholic Fatty Liver Disease: Causes, Symptoms, Risks and How to Improve It...

👁 9 2026-04-26
Read More →
Non-Alcoholic Fatty Liver: Meaning, Causes, Symptoms, and How to Improve It
health
Non-Alcoholic Fatty Liver: Meaning, Causes, Symptoms, and How to Improve It

Non-Alcoholic Fatty Liver: Meaning, Causes, Symptoms, and How to Improve It...

👁 10 2026-04-26
Read More →
The Ultimate Blueprint to Score 70/70 in ISC Class 12 Computer Science
class-1-12-resources
The Ultimate Blueprint to Score 70/70 in ISC Class 12 Computer Science

The Ultimate Blueprint to Score 70/70 in ISC Class 12 Computer Science...

👁 47 2026-04-11
Read More →