Hi there,
I need some help with formatting on my program. I can't seem to get the table to look like this:
Code:
1 2 3 4
-------------------
1 1 2 3 4
2 2 4 6 8
3 3 6 9 12
4 4 8 12 16
Here is my code:
Code:
#include <stdio.h>
int mult(int x, int y);
int main(void)
{
int x, y;
for (x = 1; x < 10; x++) {
printf("%4d", x);
}
printf("\n");
printf("-------------------------------------\n");
for (y = 1; y < 10; y++) {
printf("%d\n", y);
}
for (x = 1; x < 10; x++) {
for (y = 1; y < 10; y++) {
printf("%4d", mult(x, y));
}
}
return (0);
}
int mult(int x, int y)
{
return(x * y);
}
Now, I realize this would be 100x easier with arrays, but we haven't learned them in class yet, so I need to use loops. I just don't know how to get the numbers I need on the lines I want, like shown above.
Help/Tips appreciated.