In this problem, what is the role of Show
Output: For a number (Say '3') without
with
asked Jul 29 at 10:20
3 When you are printing asterisks or spaces with:
and
those print statements are not advancing a line due to the "end=' '" bit. That is why you get either an asterisk or space printing one after another. The line of code:
isn't actually printing anything, but it is sending a carriage return and line feed to advance to the next line. So if you have a print statement that does not include the "end=' '" directive, your terminal output will advance to the next line.
halfer 19.6k17 gold badges92 silver badges176 bronze badges answered Jul 29 at 16:06
NoDakkerNoDakker 2,1311 gold badge8 silver badges9 bronze badges View Discussion Improve Article Save Article View Discussion Improve Article Save Article For any given number n, print Hollow and solid Squares and Rhombus made with stars(*). Input : n = 4 Output : Solid Square: **** **** **** **** Hollow Square: **** * * * * **** 1. Solid Square : Solid Square is easiest among all given patterns. To print Solid square with n rows, we should use two loops iterating n times both. Where the outer loop is used for numbers of rows and the inner loop is used for printing all stars in a particular row. C++
Java
Python3
C#
PHP
Javascript
Output : Solid Square: ***** ***** ***** ***** ***** Hollow Square: ***** * * * * * * ***** Time Complexity: O(n2), where n represents the
given input. This article is contributed by Shivam Pradhan (anuj_charm). If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article
to . See your article appearing on the GeeksforGeeks main page and help other Geeks. |