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.  
  14. addArrays(a, b, c, 3);
  15.  
  16. printf("Resultant array c: ");
  17. for (int i = 0; i < 3; i++) {
  18. printf("%d ", c[i]);
  19. }
  20. printf("\n");
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Resultant array c: 5 7 9