Okay, I've got the 1st numbers in each row correct, but I can't figure out why the other numbers are off. I'm on about hour 7 on something that shouldn't be that hard so I'll a little frustrated. Any help is appreciated, thanks.
Code:
Desired Output:
1 2 4 7
3 5 8
6 9
0
Actual:
1 3 4 5
3 6 7
6 0
0
Here is my code:
Code:
main()
{
printf("Enter size and seed: ");
scanf("\n%i %i", &size, &seed);
rnum = seed;
for(row = 1; row <= size; row++)
{
for(col = 1; col <= size; col++)
{
if(col == row)
{
if(row == 1)
{
printf("%i ", seed);
}
else
{
rnum = y + row;
if(rnum > 9)
{
printf("%i ", rnum%10);
}
else
{
printf("%i ", rnum);
}
}
y = rnum;
}
else if(col > row)
{
cnum = rnum + col;
printf("%i ", cnum%10);
}
else
{
printf(" ");
}
}
printf("\n");
}
}