C Language: Implement a function to print the multiplication tables, tables of the number of rows and columns of their own designation

Source: Internet
Author: User
Tags mul

Implement a function to print the multiplication table, the number of rows and the number of columns of the table itself specified,

Input 9, output 9*9 table, output , output 12*12 multiplication table.

Program:

#include <stdio.h>

void mul (int n) //multiplication Multiplication

{

int I, J;

for (i = 1; I <= n; i++)

{

for (j = 1; J <= I; j + +)

{

printf ("%d*%d=%-2d", I, J, i*j);

Where 2 in%2d means output two cells, number backward, that is, right-justified;%-2d, the number is left-justified

}

printf ("\ n");

}

}

int Main ()

{

int n=0;

printf ("Please enter the line of the multiplication table:");

scanf ("%d", &n);

Mul (n);

return 0;

}

Results:

Please enter the line for the multiplication table :

1*1=1

2*1=2 2*2=4

3*1=3 3*2=6 3*3=9

4*1=4 4*2=8 4*3=12 4*4=16

5*1=5 5*2=10 5*3=15 5*4=20 5*5=25

6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36

7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49

8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64

9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81

10*1=10 10*2=20 10*3=30 10*4=40 10*5=50 10*6=60 10*7=70 10*8=80 10*9=90 10*10=100

11*1=11 11*2=22 11*3=33 11*4=44 11*5=55 11*6=66 11*7=77 11*8=88 11*9=99 11*10=110 11*11=121

12*1=12 12*2=24 12*3=36 12*4=48 12*5=60 12*6=72 12*7=84 12*8=96 12*9=108 12*10=120 12*11=132 12*12=144

Please press any key to continue ...


This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1722387

C Language: Implement a function to print the multiplication tables, tables of the number of rows and columns of their own designation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.