This is the change I made. I still get the Segmentation Fault error as well as no new line at end of file warning. Please check.
Code:
#include <stdio.h>
int asksize(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// Series means from 1 to 10, 10 is the last digit. So if a user inputs the size. the square generates from 1 to n, where n is the last digit.
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]; //What is wrong with this declaration, as
the user will be giving the size of the array
n = asksize();
for (row = 0; row < n; row++)
{
printf("\n");
for (column = 0; column < n; column++)
{
square[row][column] = recursion(row, column, n);
printf("%d", square[row][matrix]); // Prints the Result
}
}
putchar('\n');
return 0;
}