Here is my code: Code: #include <stdio.h> #include <stdlib.h> #define ROWS_LENGHT 10 void inputNums(int timesTable[][ROWS_LENGHT]); void printTable(int timesTable[][ROWS_LENGHT]); int main() { int timesTable[ROWS_LENGHT][ROWS_LENGHT] = {0}; inputNums(timesTable); printTable(timesTable); return 0; } void inputNums(int timesTable[][ROWS_LENGHT]) { int i = 0; int j = 0; for(i = 1 ; i <= ROWS_LENGHT ; i++) { for(j = 1 ; j <= ROWS_LENGHT ; j++) { timesTable[j] = i*j; } } } void printTable(int timesTable[][ROWS_LENGHT]) { int i = 0; int j = 0; int number = 1; for(i = 1 ; i <= ROWS_LENGHT ; i++) { for(j = 1 ; j <= ROWS_LENGHT ; j++ ) { if(number % 11 == 0) { printf("\n"); printf("%d ",timesTable[j]); } else { printf("%d ",timesTable[j]); } } } } Im almost sure that i get overflow, even thou i dont use more the 11 arrays 11 places in every array.
Hey there, Well in the first loop you can change the value of "i" to 0 as indicated by shabbir, but there is one more thing that might be coming in your way which is the initial value of "j" which you've initialized the same as that of "i". I'd recommend try initializing the value of "j=i+1" this should solve your issue. Hope it helps. Cheers