so I am trying to make a triangle in which :
1. The number of elements in a row is equal to the row number
2. Each element is the product of the row number by the column number.
Example Output:
Enter a number: 7
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 49
However when I run the program all I get is:
Enter a number: 7
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
PLEASE HELP!!! Thanks in advance
Heres my code as of now:
Code:
#include <stdio.h>
int main ()
{
int num, row, col;
printf("Enter a number: ");
scanf("%d", &num);
for (col = 1; col <= num; col++) {
for (row = 1; row <= col; row++) {
col = col*row;
printf("%5d", col);
}
printf("\n");
}
}