From a0ef49d0ffd6dc366324fb486ceecf474c77306d Mon Sep 17 00:00:00 2001 From: mandiraghosh783 Date: Wed, 8 Dec 2021 23:32:36 +0530 Subject: [PATCH] pattern program added --- cpp/pascals-triangle.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cpp/pascals-triangle.cpp diff --git a/cpp/pascals-triangle.cpp b/cpp/pascals-triangle.cpp new file mode 100644 index 0000000..e952f6e --- /dev/null +++ b/cpp/pascals-triangle.cpp @@ -0,0 +1,31 @@ +#include + int main() + {int n,i,j; + printf("enter n\n"); + scanf("%d",&n); + + int sp = n / 2; + int st = 1; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= sp; j++) + { + printf(" "); + } + for (int j = 1; j <= st; j++) + { + printf("* "); + } + if (i <= n / 2) + { + sp--; + st += 2; + } + else + { + sp++; + st -= 2; + } + printf("\n"); + }return 0; + }