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


程式說明

列印給定數字的乘法表

演算法

從使用者那裡接收一個數字以形成乘法表。

從值 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; }

輸出

更新於:2020 年 1 月 9 日

540 次瀏覽

開始您的職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.