aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-10-26 09:14:57 +0100
committerGitHub <noreply@github.com>2021-10-26 09:14:57 +0100
commitb984a79cf4e45d0b41da665d029a02484d126e20 (patch)
tree92f6bbd10e60db579893ea2723cd28341afc9954
parentd4af640c5e8baf60dcff6c3e994bad84ad67a4a2 (diff)
parent7626e17a8063722c39b5a07943dee655da9e47c3 (diff)
downloadperlweeklychallenge-club-b984a79cf4e45d0b41da665d029a02484d126e20.tar.gz
perlweeklychallenge-club-b984a79cf4e45d0b41da665d029a02484d126e20.tar.bz2
perlweeklychallenge-club-b984a79cf4e45d0b41da665d029a02484d126e20.zip
Merge pull request #5106 from karishmarajput/master
Solve 122-ch1
-rw-r--r--.vscode/settings.json5
-rw-r--r--challenge-122/karishma/C/ch-1.c28
2 files changed, 32 insertions, 1 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8bab9cab1f..f3364b9ae0 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,5 +1,8 @@
{
"editor.rulers": [
72,80,120,132
- ]
+ ],
+ "files.associations": {
+ "valarray": "c"
+ }
} \ No newline at end of file
diff --git a/challenge-122/karishma/C/ch-1.c b/challenge-122/karishma/C/ch-1.c
new file mode 100644
index 0000000000..0dda717765
--- /dev/null
+++ b/challenge-122/karishma/C/ch-1.c
@@ -0,0 +1,28 @@
+#include <stdio.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