首页 > 文章列表 > 打印给定数字的乘法表在C中

打印给定数字的乘法表在C中

c语言 打印 数字 乘法表
158 2023-08-27

程序描述

打印给定数字的乘法表

算法

接受用户提供的任何需要形成乘法的数字

从 I 的值开始乘以给定数 (=1)

将给定数与 I 的值递增,直到 I 值小于或等于12.

示例

/* Program to print the multiplication table of a given number */
#include <stdio.h>
int main() {
   int number, i;
   clrscr();
   printf("Please enter any number to find multiplication table:");
   scanf("%d", &number);
   printf("Multiplication table for the given number %d: ", number);
   printf("

");    for(i=1;i<=12;i++){       printf("%d x %d = %d", number, i, number * i);       printf("

");    }    getch();    return 0; }

输出

打印给定数字的乘法表在C中