Print Square Star Pattern
C++
Easy
1 views
Problem Description
Print a square pattern of stars.
Real Life: Basic pattern for learning nested loops.
Step-by-Step Logic:
1. Outer loop controls rows
2. Inner loop controls columns
3. Print star in each position
4. Move to next line after each row
Official Solution
void pattern_q1_square() {
int n = 5;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
cout << "* ";
}
cout << endl;
}
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!