fork download
  1. #include <stdio.h>
  2.  
  3. void addArrays(int a[], int b[], int c[], int size) {
  4. for (int i = 0; i < size; i++) {
  5. c[i] = a[i] + b[i];
  6. }
  7. }
  8.  
  9. int main() {
  10. int a[] = {1, 2, 3};
  11. int b[] = {4, 5, 6};
  12. int c[3];
  13. addArrays(a, b, c, 3);
  14.  
  15. printf("Resultant array c: ");
  16. for (int i = 0; i < 3; i++) {
  17. printf("%d ", c[i]);
  18. }
  19. printf("\n");
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Resultant array c: 5 7 9