1

C Program For Printing 180 Degree Rotation of Simple Pyramid

 1 year ago
source link: https://www.geeksforgeeks.org/videos/c-program-for-printing-180-degree-rotation-of-simple-pyramid/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

C Program For Printing 180 Degree Rotation of Simple Pyramid

C Program For Printing 180 Degree Rotation of Simple Pyramid
Hey guys. Welcome to Geeks for geeks. Today, we are
  • 60 Views
  • 24/08/2022

In this video, we will write a C program for printing 180-degree rotation of a simple pyramid

To print a simple pyramid, you should rotate the object 90 degrees along the y axis. This way, the pyramid will look like a regular triangle.

Example:
Input: n= 3
Output = 
*
**
***

Here we see 3 different approaches for printing a 180-degree rotation of a pyramid.

1. Using Nested for loop: First for loop is used to identify the number of rows and the second for loop is used to identify the number of columns. Here the values will be changed according to the first for loop. If j is greater than I then it will print the output otherwise print the space.

2. Using Nested While Loop: The while loops check the condition until the condition is false. If the condition is true then enters into a loop and executes the statements.

3. Using Recursion and a for loop: Here we call a recursion function with three parameters n, space, and an asterisk. After printing a simple pyramid with the help of for loop.

The time complexity will be high and space complexity will be low in the first 2 approaches, But the opposite (time complexity low and space complexity high) will happen in Approach-3.

C Program For Printing 180 Degree Rotation of Simple Half Left Pyramid
https://www.geeksforgeeks.org/c-program-for-printing-180-degree-rotation-of-simple-half-left-pyramid/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK