C Program to Generate Multiplication Table.
Example to generate the multiplication table of a number (entered by the user) using for loop.
The program takes an integer input from the user and generates the multiplication table up to 10.
Example #1: Multiplication Table Up to 10
#include <stdio.h>
#include <conio.h>
int main()
{
int n;
printf("Enter an integer: ");
scanf("%d",&n);
for(int i=1; i<=10; ++i)
{
printf("%d * %d = %d \n", n, i, n*i);
}
getch();
}
Output
Enter an integer: 9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90
Here's a little modification of the above program to generate the multiplication table up to a range (where range is also a positive integer entered by the user).
No comments: