"Multiplication table" in C Language"
The difficulty in using C language to implement a multiplication table lies in how to control the data output format, which is a deep understanding of nested for loops. First, the outer loop is assigned once, and the inner loop is executed once. For the multiplication table program, when the outer loop is 1 and the inner loop is also 1, a row and a column are printed; when the outer loop is 1 and the inner loop is 2, two columns, and so on are printed. For the sake of beauty, print in "%-4d" format, "-" indicates the left alignment, and "4d" indicates that the output Integer Data occupies at least four places, in fact, the most two are here, and the remaining two are filled with spaces. The C language code is as follows:
# Include <stdio. h> int main () {int I, j; for (I = 1; I <= 9; I ++) // outer for loop control column {for (j = 1; j <= I; j ++) // The inner for loop control line {printf ("% d * % d = %-4d", j, I, I * j); // % 4d indicates four digits, insufficient space filling} //-4 indicates left-aligned printf ("\ n");} return 0 ;}