Despite your bad explanation, i think this is what you are looking for.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[] = {1, 2, 3};
int b[] = {1, 2};
int numElementsA = sizeof(a) / sizeof(int);
int numElementsB = sizeof(b) / sizeof(int);
int finalSize = numElementsA * numElementsB;
printf("finalSize: %i\n", finalSize);
int* c = malloc(finalSize * sizeof(int));
int cc = 0;
for (int x = 0; x < numElementsA; x++) {
for (int y = 0; y < numElementsB; y++) {
c[cc] = a[x] + b[y];
cc++;
}
}
for (int i = 0; i < finalSize; i++) {
printf("%i ,", c[i]);
}
//make sure memory doesn't leak
free(c);
return 0;
}
Output:
finalSize: 6
2, 3, 3, 4, 4, 5,
4
solved How to add each elements of two unequal arrays and store it in third array? [closed]