C language practice every day - output multiplication table

Topic: Multiplication tables

Content: Output the 9*9 multiplication table on the screen

#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>


int main() {
    int a = 0;
    int b = 0;
    
    for (a = 1; a <= 9; a++) {
        for (b = 1; b <= 9; b++) {
            printf("%d*%d=%2d\t", a, b, a*b);
        }
    }

    return 0;
}

Question idea: Because two digits are multiplied in the multiplication table, the definition is initialized as two variables, which are incremented by 1 in turn, and then multiplied together to obtain a result that is no more than 9 and no less than 1. It's not difficult, it's quite simple.

operation result:

 

Guess you like

Origin blog.csdn.net/m0_58724783/article/details/131913425