From 94ba4bafd795190a194fb53cee9eed039dbe0e1a Mon Sep 17 00:00:00 2001 From: arshivaastha <78898085+arshivaastha@users.noreply.github.com> Date: Wed, 27 Oct 2021 18:05:27 +0530 Subject: [PATCH 1/2] Printing pattern solution --- .../C programs/PrintingPatternUsingLoops.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 HackerRank Problems/C programs/PrintingPatternUsingLoops.c diff --git a/HackerRank Problems/C programs/PrintingPatternUsingLoops.c b/HackerRank Problems/C programs/PrintingPatternUsingLoops.c new file mode 100644 index 0000000..7c5e480 --- /dev/null +++ b/HackerRank Problems/C programs/PrintingPatternUsingLoops.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +int main() +{ + + int n; + scanf("%d", &n); + // Complete the code to print the pattern. + + int len = n*2 - 1; + for(int i=0;i Date: Wed, 27 Oct 2021 18:08:29 +0530 Subject: [PATCH 2/2] Pointers in C --- HackerRank Problems/C programs/PointersInC.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 HackerRank Problems/C programs/PointersInC.c diff --git a/HackerRank Problems/C programs/PointersInC.c b/HackerRank Problems/C programs/PointersInC.c new file mode 100644 index 0000000..5882152 --- /dev/null +++ b/HackerRank Problems/C programs/PointersInC.c @@ -0,0 +1,20 @@ +#include + +void update(int *a,int *b) { + int x, y; + x = *a + *b; + y = *a - *b; + *a = x; + *b = abs(y); +} + +int main() { + int a, b; + int *pa = &a, *pb = &b; + + scanf("%d %d", &a, &b); + update(pa, pb); + printf("%d\n%d", a, b); + + return 0; +}