Number pattern 37 in C

Write a C program to print the given number pattern using loop. How to print the given triangular number pattern using for loop in C programming. Logic to print the given number pattern through C program.



Input N: 5


Required knowledge

Basic C programming, Loop

Logic to print the given number pattern

Before solving the given pattern have a close look to the pattern. You will find that the pattern internally can be divided in two patterns which can be shown below.

Now, what we need to do is combine the logic to print both these two patterns in single program. Logic of print both these patterns are simple and are explained in previous posts separately. You can check out these two posts to get the logic of printing first pattern and second pattern if you are unfamiliar with these two patterns.
Let's combine them into single pattern.

Program to print the given pattern

 * C program to print the given number pattern

#include <stdio.h>

int main()
    int i, j, N;

    printf("Enter rows: ");
    scanf("%d", &N);

    for(i=1; i<=N; i++)
        // Prints the first part of the pattern
        for(j=1; j<=i; j++)
            printf("%d", j);

        // Prints the second part of the pattern
        for(j=i-1; j>=1; j--)
            printf("%d", j);


    return 0;


Enter rows: 5

Happy coding 😉

About Pankaj

Pankaj Prakash is the founder, editor and blogger at Codeforwin. He loves to learn new techs and write programming articles especially for beginners. He works at Vasudhaika Software Sols. as a Software Design Engineer and manages Codeforwin. In short Pankaj is Web developer, Blogger, Learner, Tech and Music lover.

Follow on: Twitter | Google | or

Comments and discussion
Have a doubt, write here. I will help my best.
Before commenting you must escape your source code before commenting. Paste your source code inside
<pre><code> ----Your Source Code---- </code></pre>