Find a sum of 2D array, array must be generated by F. rand. why this code doesn't work ?
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); int A[4][3], B[4][3], C[4][3]; int num; for(int i=0; i < 4; i++){ for(int j=0; j<3; j++) num = rand() % (100 - 1 + 1); A[i][j] = num; A[i][j] = num; } for(int i=0; i < 4; i++){ for(int j=0; j<3; j++) printf("%d\t", A[i][j]); } for(int i=0; i < 4; i++){ for(int j=0; j<3; j++) printf("%d\t", B[i][j]); } //compute C[4][3] for(int i=0; i < num; i++){ for(int j=0; j<num; j++) C[i][j] = A[i][j] + B[i][j]; } printf("C is \n"); for(int i=0; i < 4; i++){ for(int j=0; j<3; j++) printf("%d\t", C[i][j]); } return 0; }