C Program To Display Multiplication Table Having n Multiples
C Program :
/* Aim: Write a program to display multiplication table having n multiples */ #include<stdio.h> void main() { int i,prod,a,m; printf("\n Enter a number to display table:- "); scanf("%d",&a); printf("\n How many multiples should be displayed:- "); scanf("%d",&m); printf("\n"); for(i=1;i<=m;i++) { prod=a*i; printf("%d X %d = %d \t",a,i,prod); printf("\n"); } printf("\n"); } // End of the code
/* Output of above code:
[root@localhost ~]# gcc -o e5a2 e5a2.c
[root@localhost ~]# ./e5a2
Enter a number to display table:- 2
How many multiples should be displayed:- 10
2 X 1 = 2
2 X 2 = 4
2 X 4 = 8
2 X 5 = 10
2 X 6 = 12
2 X 7 = 14
2 X 8 = 16
2 X 9 = 18
2 X 10 = 20 */