คำอธิบายโปรแกรม
พิมพ์ตารางคูณของตัวเลขที่กำหนด
อัลกอริทึม
รับตัวเลขจากผู้ใช้ที่ต้องการสร้างตารางคูณ
คูณตัวเลขที่กำหนด เริ่มจากค่า 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: \n", number);
for (i = 1; i <= 12; i++) {
printf("%d x %d = %d\n", number, i, number * i);
}
// getch();
return 0;
}
เอาต์พุต
แสดงตารางคูณ 1-12 ของตัวเลขที่ป้อน