So i wrote a code to calculate the multiplication of two matrixes. The programm is doing its job by producing the correct outcome. I provide most of the output fuction below:
for (i = 0; i < row; ++i)
{
for (j = 0; j < column; ++j)
{
printf("%d ", result[i][j]);
if (j == column -1)
printf("\n");
}
}
The last two lines help with the correct pressentation of the result, e.g.:
xxx xx
x -xx
x x
where as x stands for an integer. How am I gonna make the programm end without a new line? e.g.:
xxx xx
x -xx
x xPress any key to continue...
instead of what i am getting now:
xxx xx
x -xx
x x
Press any key to continue...
Thanks in advance.
The asnwer was trivial, the point is to present the output in an acceptable way for a testing machine, meaning there had to be no space after the end of every new line in order for the test to be passed. I had some troube understanding the logic behind it but eventually after some searching, some help from above and a day of trial and error i figured it out.
for (i = 0; i < row; ++i)
{
for (j = 0; j < column; ++j)
{
printf(j == column -1 ? "%d" : "%d ", result[i][j]);
if (i != row -1 && j == column -1)
printf("\n");
}
}