aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkarishmarajput <karrajput3948@gmail.com>2021-10-26 12:44:19 +0530
committerkarishmarajput <karrajput3948@gmail.com>2021-10-26 12:58:01 +0530
commit7626e17a8063722c39b5a07943dee655da9e47c3 (patch)
tree92f6bbd10e60db579893ea2723cd28341afc9954
parentd4af640c5e8baf60dcff6c3e994bad84ad67a4a2 (diff)
downloadperlweeklychallenge-club-7626e17a8063722c39b5a07943dee655da9e47c3.tar.gz
perlweeklychallenge-club-7626e17a8063722c39b5a07943dee655da9e47c3.tar.bz2
perlweeklychallenge-club-7626e17a8063722c39b5a07943dee655da9e47c3.zip
Solve ch-122-1
-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