From 4b1ebc85f8f538e2be54ce32d49fa44b3a0d2f01 Mon Sep 17 00:00:00 2001 From: sachin7460 <56535317+sachin7460@users.noreply.github.com> Date: Mon, 14 Oct 2019 13:41:18 +0530 Subject: [PATCH] Create pramid pattern --- cpp/pramid pattern | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 cpp/pramid pattern 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; +}