Can anyone check ths code and tell me whats wrong? Im getting a Segmentation fault [COREDUMP] when im runnig my program. I do not get any error when compiling.
Code:#include <stdio.h> int size(void) { int n; //size of matrix printf ("What is the size of the matrix?"); //user input scanf ("%d",&n); return n; } int recursion (int row, int column, int n) //Recursive function { int result; result = ((row + 1) + column) % n; // If the result is 0, n will be returned. n is the last digit in the series if (result == 0) { return n; } else { return result; } } int main () { int row; //row of the matrix int column; // column of the matrix int n; // n is the size of the matrix as mentioned in the question int square[n][n]; n = size(); for (row = 0; row < n; row++) { printf("\n"); for (column = 0; column < n; column++) { square[row][column] = recursion(row, column, n); printf("%d", square); // Prints the Result } } return 0; }



LinkBack URL
About LinkBacks


