VOOZH about

URL: https://www.geeksforgeeks.org/dsa/print-solid-rectangle-star-pattern/

⇱ Print Solid Rectangle Star Pattern - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Print Solid Rectangle Star Pattern

Last Updated : 13 Mar, 2026

Given two integers n and m, print a solid rectangle pattern of stars with n rows and m columns. Each row has exactly m stars.

Examples:

Input: n = 3, m = 5

Output:

👁 420851457

Input: n = 4, m = 2

Output:

👁 420851458

Using Nested Loops – O(n*m) Time and O(1) Space

The pattern can be printed using two nested loops. The outer loop runs once for each row, while the inner loop runs for each column in that row, printing stars. After printing all the stars in a row, a newline is added to move to the next row.


Output
* * * * * 
* * * * * 
* * * * * 
Comment
Article Tags: