Number pattern 48 in C

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

Example

Input

Input N: 5

Output

Required knowledge

Basic C programming, Loop

Program to print the given number pattern

/**
 * C program to print the given number pattern
 */

#include <stdio.h>

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

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

    for(i=1; i<=N; i++)
    {
        for(j=i; j<=(i*i); j += i)
        {
            printf("%-3d", j);
        }

        printf("\n");
    }

    return 0;
}

Output

Enter N: 5
1
2  4
3  6  9
4  8  12 16
5  10 15 20 25

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>