Originally Posted by
frterwil
Thanks. I just got rid of the loop() and just called the main. There was no reason to add that complication.
Oh well, the neat of doing this is by calling the loop from main and not calling the main recursively. Look bellow:
Code:
#include <stdio.h>
#include <stdlib.h>
int loop( void );
int main()
{
loop();
return EXIT_SUCCESS;
}
int loop( void )
{
int size, seed, row, col;
int cnum, rnum, space, x, y;
printf("Enter size and seed: ");
int n = scanf("%i %i", &size, &seed);
if(n == 2)
{
for(row = 1; row == size; row++)
{
printf("%i", seed);
for(col = 1; col == size; col++)
{
cnum = seed;
if((x = cnum + col) <= 9)
printf("%i ", x);
else
{
y = x - 10;
printf("%i ", y);
}
}
printf("\n");
for(space = row; space == 0; space--)
printf(" ");
}
}
else
{
printf("Size and seed must both be between 1 and 9.");
loop();
}
}
I am not very sure about the recursive function here. That is gonna be in a infinite loop unless you put some condition some where in the function so that it could break and return to main.
Hope that help on how to follow it up.
-ssharish