for (y = 1; y < num1 + 1; y++)
{
for(x = 1; x < num2 + 1; x++)
{
if (y >= 1 && y <= 4 && x >= 1 )
{
printf ("%d x %d = %d", y, x, y*x);
printf (" || ");
}
else if (y >= 5 && y <= 9)
{
printf ("%d x %d = %d", y, x, y*x);
printf (" || ");
}
else if (y == 10)
{
printf ("%d x %d = %d", y, x, y*x);
printf (" || ");
}
}
if (y >= 1 && y <= 8)
{
printf ("\n");
printf(" ");
}
else if (y == 9)
{
printf ("\n");
printf(" ");
}
}
I tried changing the for loop to do while + while but doesn't seem to work.
do
{
while( x <= num2)
{
if (y >= 1 && y <= 4)
{
printf ("%d x %d = %d", y, x, y*x);
printf (" || ");
}
else if (y >= 5 && y <= 9)
{
printf ("%d x %d = %d", y, x, y*x);
printf (" || ");
}
else if (y == 10)
{
printf ("%d x %d = %d", y, x, y*x);
printf (" || ");
}
x++;
}
if (y >= 1 && y <= 9)
{
printf ("\n");
printf (" ");
}
else if ( y == 10)
{
printf ("\n");
printf (" ");
}
y++;
}
while (y != num1 + 1);