Example: Rectangle Made of N x N Stars
Write a program that gets a positive integer n and prints on the console a rectangle made out of N x N stars.
Input | Output | Input | Output | Input | Output |
---|---|---|---|---|---|
2 | ** ** |
3 | *** *** *** |
4 | **** **** **** **** |
Video: Rectangle of N x N Stars
Watch this video lesson to learn how to print a rectangle of N x N stars on the console using nested for-loops: https://youtu.be/9sB4Z2TI1AE.
Hints and Guidelines
This is sample solution, which uses a single loop, holding a command to print n
stars:
You may also use nested for-loops: outer loop 1..n for the rows and inner loop 1…n for the columns, which prints a single star.
Testing in the Judge System
Test your solution here: https://judge.softuni.org/Contests/Practice/Index/512#1.