C++ Program to print pattern 2*N Number of rows

To Print 2*N Number of rows pattern

In this article we will learn to print 2*N row patterns of numbers, where we need to use many loops in C++ programming language.Here ‘i’ loop is used to access each line from 1 to N and ‘j’ loop is used to print values in each line.
Here we are given you solution to deal with this problem.

C++ Program to print pattern 2*N Number of rows

Implementation:-

  • Given input from user i.e number of lines required (2*N value).
  • Take a result variable (say ‘num’).
  • Take two loops and two subloops one for each line (say ‘i’) and other for each digit in a particular line (say ‘j’).
  • Here ‘i’ loop is used to access each line from 1 to N and ‘j’ loop is used to print values in each line.
  • Decrement the ‘a’ value at the beginning of each line to 2*N values.
  • Repeat the ‘i’ loop until it reaches ‘N’ lines.

2 comments on “C++ Program to print pattern 2*N Number of rows”


  • Bhagyashree

    // INCLUDE HEADER FILES NEEDED BY YOUR PROGRAM
    // SOME LIBRARY FUNCTIONALITY MAY BE RESTRICTED
    // DEFINE ANY FUNCTION NEEDED
    // FUNCTION SIGNATURE BEGINS, THIS FUNCTION IS REQUIRED
    #include
    using namespace std;
    void incrementPatternPrint(int s, int n)
    {

    int i=0,j=0,k=0;
    int row=1;
    for(i=s;in)
    {
    break;
    }
    else
    {
    row++;
    }
    for(j=1;j<row;j++)
    {
    cout<<i;

    }
    cout<=s-1;i–)
    {
    if(row=1;j–)
    {
    cout<<i;

    }
    cout<<endl;
    }
    }
    // FUNCTION SIGNATURE ENDS


  • CHINTA

    n = int(input())
    m=n-1
    for i in range(1,2*n+1):
    if i < n or i == n:
    print(i*str(m))
    m=m+1
    else:
    m = m-1
    print((2*n-i)*str(m-1))