Nine-nine multiplication table-C language implementation
With the help of C language loop to realize the multiplication table of nine to nine, the formatted positive sequence is required to be displayed on the terminal.
#include<stdio.h>
//借助for()的两层循环,外循环决定*左边的数,内循环决定*右部的数。
//内循环每执行一次输出一次并用'\t'格式化水平制表。
//内循环结束进行换行。
int main()
{
int i, j;
for (i = 1; i < 10; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d*%d=%d",i,j,i*j);
putchar('\t');
}
putchar('\n');
}
return 0;
}
Screenshot of program running (Visual Stdio 2019 compiler)
This topic mainly examines the use of loops, which can be easily achieved with the help of for loop nesting.
Error-prone point: the end of the inner loop is linked to the end condition of the outer loop.