Print Right Triangle Pattern

Print Right Triangle Pattern

Easy C++ Pattern Printing 41 views
Explanation Complexity

Problem Statement

Print stars in increasing pattern (right triangle).
Real Life: Understanding row-dependent printing.

Input Format

An integer n (number of rows).

Output Format

Right-angled triangle pattern using *.

Example

4
*
**
***
****

Constraints

• n ≥ 1

• Use loops only

Concept Explanation

Stars are printed in increasing order.
Each row prints stars equal to the row number.
This depends directly on the row count.

Step-by-Step Explanation

1.Take input n.

2.Loop rows from 1 to n.

3.For each row i:

• Print i stars using an inner loop.

5.After printing stars of a row, move to next line

Concept Explanation

Stars are printed in increasing order.
Each row prints stars equal to the row number.
This depends directly on the row count.

Step-by-Step Explanation

1.Take input n.

2.Loop rows from 1 to n.

3.For each row i:

• Print i stars using an inner loop.

5.After printing stars of a row, move to next line

Input / Output Format

Input Format
An integer n (number of rows).
Output Format
Right-angled triangle pattern using *.
Constraints
• n ≥ 1

• Use loops only

Examples

Input:
4
Output:
* ** *** ****

Example Solution (Public)

C++
void pattern_q2_right_triangle() {
    int n = 5;
    
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= i; j++) {
            cout << "* ";
        }
        cout << endl;
    }
}

Official Solution Code

void pattern_q2_right_triangle() {
    int n = 5;
    
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= i; j++) {
            cout << "* ";
        }
        cout << endl;
    }
}
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.