Print Inverted Triangle Pattern
C++
Easy
5 views
Problem Description
Print stars in decreasing pattern.
Real Life: Reverse of right triangle.
Step-by-Step Logic:
1. Row 1: print n stars
2. Row 2: print n-1 stars
3. Last row: print 1 star
4. Stars decrease each row
Official Solution
void pattern_q3_inverted_triangle() {
int n = 5;
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i; j++) {
cout << "* ";
}
cout << endl;
}
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!