diff --git a/cpp/pramid pattern b/cpp/pramid pattern new file mode 100644 index 0000000..f26b702 --- /dev/null +++ b/cpp/pramid pattern @@ -0,0 +1,48 @@ +// C++ implementation to print the following +// pyramid pattern +#include +using namespace std; + +// function to print the following pyramid pattern +void printPattern(int n) +{ + int j, k = 0; + + // loop to decide the row number + for (int i=1; i<=n; i++) + { + // if row number is odd + if (i%2 != 0) + { + // print numbers with the '*' sign in + // increasing order + for (j=k+1; jk-i+1; j--) + cout << j << "*"; + cout << j << endl; + } + } +} + +// Driver program to test above +int main() +{ + int n = 5; + printPattern(n); + return 0; +}