diff options
| -rw-r--r-- | .vscode/settings.json | 5 | ||||
| -rw-r--r-- | challenge-122/karishma/C/ch-1.c | 28 |
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 |
