Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int k, n, *a, *b, *c;
- printf("Subject: Given arrays a and b, consisting of n elements each. Get the array c, where c[k] = a[k] + b[k] \n");
- do {
- printf("Enter the size of the array: \n");
- scanf("%d", &n); } while (n < 1);
- a = malloc(n * sizeof(int));
- b = malloc(n * sizeof(int));
- c = malloc(n * sizeof(int));
- printf("Array:\n");
- printf("Enter a[k] \n");
- for (k = 0; k < n; k++) {
- scanf_s("%d", &a[k]);}
- printf("Enter b[k] \n");
- for (k = 0; k < n; k++) {
- scanf_s("%d", &b[k]);
- }
- for (k = 0; k < n; k++) {
- c[k] = a[k] + b[k];
- printf("%d ", c[k]);
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement