![]() |
We can utilize ‘for’ and ‘while’ loops to print a 180-degree rotation of a simple half-left pyramid in Java as follows: Example of 180-degree Rotation of Simple Half-Left PyramidRows = 5 Output : * Methods For Printing 180-Degree Rotation of Simple Half-Left PyramidThere are certain methods to Print the 180-rotated Simple Half-Left Pyramid mentioned below:
1. Using a ‘for’ loopIn this approach two for loops are utilized where, the first for loop identifies the number of rows while the second for loop identifies a number of columns. Here the values will be altered according to the first for loop. If j is greater than i then it will print the output otherwise it will print the space. Below is the implementation of the above method:Java
Output
* * * * * * * * * * * * * * * 2. Using a ‘while’ loopExplanation: The while loop checks for the condition until the condition becomes false. If the condition is true then it enters into the loop and executes the statements Below is the implementation of the above method:Java
Output
* * * * * * * * * * * * * * * Complexity of the above method
|
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |