程序描述
打印给定数字的乘法表
算法
接受用户提供的任何需要形成乘法的数字
从 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;
}
输出
请您注册登录超级码客,加载全部码客文章内容... |