πŸ’©

programierds

nested for / multiplication table

for nested + multiplication table

Here you see two loops working together: <strong>row</strong> handles the table (1, 2, 3) and <strong>col</strong> goes from 1 to 10. Use Forward/Back to control how the table fills.

1) Code and active line Active line: 1
1for (int fila = 1; fila <= 3; fila++) {
2  for (int col = 1; col <= 10; col++) {
3    int valor = fila * col;
4    printf("%d x %d = %d\n", fila, col, valor);
5  }
6}
Step 1: The outer for starts with row = 1.
Step 1 / 13
./for-anidadostdout
2) Internal state
fila1
col1
valor (fila * col)1
Outer conditiontrue
Inner conditiontrue
3) Live multiplication table
x 12345678910
1
2
3