aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-10-31 22:48:15 +0000
committerGitHub <noreply@github.com>2021-10-31 22:48:15 +0000
commit2b4ad0c33ef7f19267d4c664f368a9edbb321ac2 (patch)
tree0b3b2f8dfaef2b704900e256db66a35f3ef2b49b
parentc1b183b554d28ea9e87f9b117c2373cc12afe051 (diff)
parenteda45dacb7a71958f1be936d8f98d217699484a1 (diff)
downloadperlweeklychallenge-club-2b4ad0c33ef7f19267d4c664f368a9edbb321ac2.tar.gz
perlweeklychallenge-club-2b4ad0c33ef7f19267d4c664f368a9edbb321ac2.tar.bz2
perlweeklychallenge-club-2b4ad0c33ef7f19267d4c664f368a9edbb321ac2.zip
Merge pull request #5131 from karishmarajput/master
Add ch-122 part 1 solution in js
-rw-r--r--challenge-122/karishma/C/ch-1.c30
-rwxr-xr-xchallenge-122/karishma/c++/ch1bin0 -> 17320 bytes
-rw-r--r--challenge-122/karishma/c++/ch1.cpp17
-rw-r--r--challenge-122/karishma/js/ch-1.js6
4 files changed, 53 insertions, 0 deletions
diff --git a/challenge-122/karishma/C/ch-1.c b/challenge-122/karishma/C/ch-1.c
new file mode 100644
index 0000000000..d52a21d311
--- /dev/null
+++ b/challenge-122/karishma/C/ch-1.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include<stdlib.h>
+
+int main() {
+ int n=0;
+ int* ptr;
+ printf("Enter total number of inputs to be entered: ");
+ scanf("%d", &n);
+ ptr = (int*)calloc(n, sizeof(int));
+ if (ptr == NULL) {
+ printf("Memory not allocated.\n");
+ exit(0);
+ }
+ else {
+ for (int i = 1; i <= n; i++) {
+ int temp=0;
+ scanf("%d",&temp);
+ ptr[i] = temp;
+ }
+ printf("\n");
+ }
+ int sum = 0;
+ for (int j = 1; j <= n; j++) {
+ sum += ptr[j];
+ printf("%d ", sum / j);
+ }
+ printf("\n");
+ free(ptr);
+ return 0;
+} \ No newline at end of file
diff --git a/challenge-122/karishma/c++/ch1 b/challenge-122/karishma/c++/ch1
new file mode 100755
index 0000000000..97181945e7
--- /dev/null
+++ b/challenge-122/karishma/c++/ch1
Binary files differ
diff --git a/challenge-122/karishma/c++/ch1.cpp b/challenge-122/karishma/c++/ch1.cpp
new file mode 100644
index 0000000000..821e88134d
--- /dev/null
+++ b/challenge-122/karishma/c++/ch1.cpp
@@ -0,0 +1,17 @@
+#include <iostream>
+using namespace std;
+
+int main() {
+ int n=5;
+ int ptr[]={10,20,30,40,50};
+ int sum = 0;
+ for (int j = 1; j <= n; j++) {
+ sum += ptr[j-1];
+ int k= sum/j;
+ cout<<k;
+ cout<<endl;
+ }
+ cout<<endl;
+
+ return 0;
+} \ No newline at end of file
diff --git a/challenge-122/karishma/js/ch-1.js b/challenge-122/karishma/js/ch-1.js
new file mode 100644
index 0000000000..c6be964b11
--- /dev/null
+++ b/challenge-122/karishma/js/ch-1.js
@@ -0,0 +1,6 @@
+let input = [10,20,30,40,50];
+let sum = 0;
+for (let j = 1; j <= 5; j++) {
+ sum += input[j-1];
+ console.log(sum/j);
+} \ No newline at end of file