Last active
November 12, 2022 08:03
-
-
Save fasalmbt/0e34e3006503212074d123712bfd6df6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int row, col; | |
/* | |
can be used for left traingle and pyramid pattern with space | |
* | |
* * | |
* * * | |
* * * * | |
* * * * * | |
and | |
* | |
** | |
*** | |
**** | |
***** | |
****** | |
*/ | |
void patternPyramid(int range) | |
{ | |
for (row = 1; row <= range; row++) | |
{ | |
for (col = ((range - row) + 1); col >= 1; col--) | |
{ | |
std::cout << " "; | |
} | |
for (col = 1; col <= row; col++) | |
{ | |
std::cout << "*"; | |
} | |
std::cout << "\n"; | |
} | |
} | |
int main() | |
{ | |
patternPyramid(8); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment