Skip to content

Instantly share code, notes, and snippets.

@fasalmbt
Last active November 12, 2022 08:03
Show Gist options
  • Save fasalmbt/0e34e3006503212074d123712bfd6df6 to your computer and use it in GitHub Desktop.
Save fasalmbt/0e34e3006503212074d123712bfd6df6 to your computer and use it in GitHub Desktop.
#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