首页  >  文章  >  后端开发  >  打印给定数字的乘法表在C中

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

王林
王林转载
2023-09-06 11:53:051302浏览

程序描述

打印给定数字的乘法表

算法

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

从 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("</p><p>");
   for(i=1;i<=12;i++){
      printf("%d x %d = %d", number, i, number * i);
      printf("</p><p>");
   }
   getch();
   return 0;
}

输出

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

以上是打印给定数字的乘法表在C中的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除