Pattern Question (print number pattern in c plus plus) with source code and small explanation 05 || Print pattern using c++ with 5 rows and 5 columns

 Here I am going to print following pattern (  the number pattern ) using c plus plus language.





ALGORITHM FOR PRINTING STAR PATTERN IN ASCENDING ORDER :

  1. header file include
  2. use namespace which standard in c plus plus
  3. Program's starting point : main() function
  4. declared two variable a
  5. get input of variable a
  6. use for loop for row till a
  7. use again for loop till current row number (i)
  8. to achieve this pattern we have to print row numbers only till column(j) which is equal to row number (i)
  9. print row number using cout 
  10. break line using line break endl after completing row.
  11. return 0 to show that there is no error in the program.

#include <iostream>
using namespace std;

int main(){
    int a;
    cin>>a;

    for (int i = 1; i <= a; i++)
    {
        for (int j = 1; j <= i; j++)
        {          
           
            cout<<i;
        }
        cout<<endl;
    }
    return 0;
}

Comments