首頁  >  文章  >  後端開發  >  列印給定數字的乘法表在C中

列印給定數字的乘法表在C中

王林
王林轉載
2023-09-06 11:53:051303瀏覽

程式描述

列印給定數字的乘法表

演算法

#接受用戶提供的任何需要形成乘法的數字

#從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刪除