Here is the C program to print multiplication table of a number till N terms. Given a number N, we have to print the multiplication table of N till T terms.
For Example
Multiplication table of 5 till 6 terms5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 5 X 6 = 30
C program to print multiplication table of a number
In this program, we first take a number n and term as input from user using scanf function. Then using a for loop we print the multiplication table of n using printf function.
#include <stdio.h>
int main() {
int n, term, i;
printf("Enter a number to print multiplication table\n");
scanf("%d",&n);
printf("Enter number of terms in table\n");
scanf("%d",&term);
/*Prints multiplication table */
printf("--------------------\n");
for(i = 1; i <= term; ++i){
printf("%d X %d = %d\n", n, i, n*i);
}
return 0;
}
Output
Enter a number to print multiplication table 8 Enter number of terms in table 11 -------------------- 8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 8 X 9 = 72 8 X 10 = 80 8 X 11 = 88
Related Topics